Dictionaries Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What type of data type is a dictionary?

A

Abstract data type

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

Define dictionary

A

An unordered collection of data as a set of key-value pairs

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

What data type is a key?

A

Any simple data type

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

Name 4 standard dictionary operations

A

retrieve a value associated with a particular key
insert a new key-value pair into the collection
remove a key-value pair from the collection
update a value associated with a key

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

Advantages of using a key

A

Allows direct access to items stored within the collection

Provides faster access to unordered data

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

How are dictionaries usually implemented?

A

Using hash tables

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

Are dictionaries unordered or ordered and why?

A

Unordered because data is arranged to optimise the speed of retrieving by key

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

How is a key used?

A

The same way as an index for an array is

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

What do you need to insert a new value?

A

A unique key and the data

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