Dictionaries and Maps

► Understanding Dictionaries

Dictionaries store data in key-value pairs, allowing fast lookup by key. They’re like real-world dictionaries where you look up a word (key) to find its definition (value).

► Real-World Analogy

Think of dictionaries like a phone book:
» Each name (key) maps to a phone number (value)
» You search by name to quickly find the number
» Each name is unique, just like dictionary keys
» You can add, update, or remove entries
» Much faster than checking each entry in a list

► Key Concepts

✓ Key-value pairs: Each key maps to one value
✓ Unique keys: No duplicate keys allowed
✓ Mutable: Can add, modify, delete entries
✓ Fast lookup: O(1) average time complexity
✓ Curly braces: Created with {}

■ Code Examples