Dictionaries
No description yet. This curated deck is ready for daily study.
Card preview (9)
What type of data type is a dictionary?
Abstract data type
Define dictionary
An unordered collection of data as a set of key-value pairs
What data type is a key?
Any simple data type
Name 4 standard dictionary operations
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
Advantages of using a key
Allows direct access to items stored within the collection Provides faster access to unordered data
How are dictionaries usually implemented?
Using hash tables
Are dictionaries unordered or ordered and why?
Unordered because data is arranged to optimise the speed of retrieving by key
How is a key used?
The same way as an index for an array is
What do you need to insert a new value?
A unique key and the data