Presentation is loading. Please wait.

Presentation is loading. Please wait.

CH 9 : MAPS AND DICTIONARIES 1 ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++, GOODRICH, TAMASSIA.

Similar presentations


Presentation on theme: "CH 9 : MAPS AND DICTIONARIES 1 ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++, GOODRICH, TAMASSIA."— Presentation transcript:

1 CH 9 : MAPS AND DICTIONARIES 1 ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++, GOODRICH, TAMASSIA AND MOUNT (WILEY 2004) AND SLIDES FROM JORY DENNY AND MUKULIKA GHOSH

2 OUTLINE  Map ADT (Ch. 9.1)  Dictionary ADT (Ch. 9.5)  Ordered Map ADT (Ch. 9.3) 2

3 MAP  A map models a searchable collection of key-value pair (called entries)  Multiple items with the same key are not allowed  Often called “associative” containers  Applications:  address book or student records  mapping host names (e.g., cs16.net) to internet addresses (e.g., 128.148.34.101) 3

4 MAP ADT 4

5 LIST-BASED MAP IMPLEMENTATION tail header nodes/positions entries 9 c 6 c 5 c 8 c 5

6 DIRECT ADDRESS TABLE MAP IMPLEMENTATION 6

7 DICTIONARY ADT (CH 9.5)  The dictionary ADT models a searchable collection of key-value entries  The main difference from a map is that multiple items with the same key are allowed  Any data structure that supports a dictionary also supports a map  Applications:  Dictionary which has multiple definitions for the same word 7

8 EXERCISE: DICTIONARY ADT 8

9 DICTIONARY ADT 9

10 ORDERED MAP/DICTIONARY ADT (CH 9.3)  An Ordered Map/Dictionary supports the usual map/dictionary operations, but also maintains an order relation for the keys.  Naturally supports  Ordered search tables - store dictionary in a vector by non-decreasing order of the keys  Utilizes binary search 10

11 EXAMPLE OF ORDERED MAP: BINARY SEARCH 13457 8 91114161819 1 3 457891114161819 134 5 7891114161819 1345 7 891114161819 0 0 0 0 m l h m l h m l h l  m  h 11

12 MAP/DICTIONARY IMPLEMENTATIONS Space Unsorted list Direct Address Table (map only) Ordered Search Table (ordered map/dictionary) Space Unsorted list Direct Address Table (map only) Ordered Search Table (ordered map/dictionary) 12


Download ppt "CH 9 : MAPS AND DICTIONARIES 1 ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++, GOODRICH, TAMASSIA."

Similar presentations


Ads by Google