Dictionary ADT: Types Operations
Dictionary ADT: Types Operations
Dictionary ADT
Dictionary ADTs
Types Operations
Log File Search
Ordered Dictionary Insertion
Hash Table Removal
Skip List
1
Dictionary ADTs
Unordered vs Ordered
Ordered
Relative order determined by comparator
between keys
Total Order relation defined on keys
Unordered
No order relation is assumed on keys
Only equality testing between keys
2
Dictionary ADT: Log File
Search
Look through entire data set
O( )
Insertion
Always insert at end
O( )
Removal
First must find, then remove
O( )
Database systems
File systems
Security audit trails
3
Binary Search
Iterative
Binary Search
Recursive
4
Notes
Binary search is an example of divide-and-
conquer technique
Rule: An algorithm is O(log n) if each
constant time operation (e.g., CMP) can cut
the problem size by a fraction (e.g., half).
Corollary: If constant time is required to
reduce the problem size by a constant
amount, the algorithm is O(N).
Divide and conquer doesn’t work with linked
list, unfortunately
Many implementations
– Log File (today)
– Ordered Dictionary (today)
– Hash Table (soon)
Different styles lead to different O( ) for
– search
– insertion
– removal