Map Flashcards

1
Q

Name variations for a Map (3)

A
  1. Map
  2. Dictionary
  3. Associative Array
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Map definition…

A

An abstract Data Structure which stores data in the form of key/value pairs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is an element in a Map?

A

A key/value pair forms an element.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

A real-world example of a key/value pair.

A

ISBN book number. The ISBN is the key and the book is the value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

An array is indexed using a numerical value. What value do we use to index a map?

A

The keys.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Can a map contain duplicate keys?

A

No.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Should you use mutable keys?

A

No.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What Data Type can a key be?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What Data Type can a value be?

A

Anything.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How many values can a Key have?

A

Only one.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Can there be duplicates of Values within a Map?

A

Yes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the common under-the-hood data structure implemented by a Map?

A

A Hash Table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do Maps work? (Layman’s terms)

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the BigO Time Complexities of a Map?

A

There are the same as it’s underlying data structure.. the Hash Table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly