This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: 4/1/2003 8:39 AM Dictionaries 1 Dictionaries 6 9 2 4 1 8 < > = 4/1/2003 8:39 AM Dictionaries 2 Outline and Reading Dictionary ADT (8.1.1) Log file (8.1.1) Binary search (8.3.3) Lookup table (8.3.2) Binary search tree (9.1) Search (9.1.1) Insertion and deletion (9.1.2) Performance (9.1.4) 4/1/2003 8:39 AM Dictionaries 3 Dictionary ADT The dictionary ADT models a searchable collection of key- element items The main operations of a dictionary are searching, inserting, and deleting items Multiple items with the same key are allowed Applications: address book credit card authorization mapping host names (e.g., cs16.net) to internet addresses (e.g., 220.127.116.11) Dictionary ADT methods: find (k): if the dictionary has an item with key k, returns the position of this item, else, returns a null position. insertItem (k, o): inserts item (k, o) into the dictionary removeElement (k): removes the item with key k from the dictionary. If no such element exists, an error occurs. size (), isEmpty () keys (), Elements () 4/1/2003 8:39 AM Dictionaries 4 Log File A log file is a dictionary implemented by means of an unsorted sequence We store the items of the dictionary in a sequence (based on a doubly-linked lists or a circular array), in arbitrary order Performance:...
View Full Document