Fundamentals of Data Structures - Notes Flashcards
Abstract data types
They make use of other data structures to form a new way of storing data
Advantage of using adjancency list
Memory Efficient as only stores the edges that exist in the graph
Disadvantage of adjancency list
Time ineffiecient as slow to query, as each item in a list must be searched sequentially until the desired edge is found
Disadvantage of using adjancency matrix
Memory ineffiecient as stores every possible edge between nodes, even those that dont exist and half of the graph is repeated
Advantage of using adjancency matrix
Time effiecient as allows a specific edge to be queried very quickly, as it can be looked up by its row and column
What is a dictionary
A collection of key value pairs in which the values is accessed by its associated key.
How do dynamic data strucutres work
Each item of data is stored in the structure alongside a reference to where the next item is stored in memory. If the number of data items exceeds the number of memory locations allocated to the strucutre, new memory locations are simply added to the structure until there is enough space for the data.
Describe the steps of rehashing
A larger hash table is created
Each value in the existing table is inserted into the new table
In a position determined by a new hashing algorithm
Explain how a value is stored in a hash table
Hashing algorithm applied to the key
The result is an index of where to store the value in an array
It is possible that the hashing algorithm might generate the same key for two different values which is called a collision
Why is hashing used
So that searching, adding and deleting can be done efficiently