Map Flashcards
Name variations for a Map (3)
- Map
- Dictionary
- Associative Array
Map definition…
An abstract Data Structure which stores data in the form of key/value pairs.
What is an element in a Map?
A key/value pair forms an element.
A real-world example of a key/value pair.
ISBN book number. The ISBN is the key and the book is the value.
An array is indexed using a numerical value. What value do we use to index a map?
The keys.
Can a map contain duplicate keys?
No.
Should you use mutable keys?
No.
What Data Type can a key be?
Any, primitive or Object. Just make sure that for Objects they are immutable and that their object and value equality checks are taken into consideration.
What Data Type can a value be?
Anything.
How many values can a Key have?
Only one.
Can there be duplicates of Values within a Map?
Yes.
What is the common under-the-hood data structure implemented by a Map?
A Hash Table.
How do Maps work? (Layman’s terms)
Maps are built on HashTables, and the values in our key/value pairs are stored in memory IN these hash tables at indexes which are determined by a hash function.
What are the BigO Time Complexities of a Map?
There are the same as it’s underlying data structure.. the Hash Table.