Week 3 Graphs & hash tables Flashcards
(8 cards)
1
Q
What does the hash function do?
A
1.Converts input (key) into a fixed-size integer, the hash code.
2.Ensures uniform distribution to minimise collisions.
2
Q
How does the hash function resolve collisions?
A
- Separate Chaining: Stores collided keys in a linked list or other structure.
- Open Addressing: Finds the next available slot using methods like linear
probing or quadratic probing.
3
Q
Hash table load factor?
A
The ratio of stored elements to the number of slots.
4
Q
Hash table resizing?
A
Rehashing to a larger table size when the load factor exceeds a
threshold.
5
Q
Hash table implementation performance optimisation consideration?
A
Aim for O(1) average-case time complexity for insertion, deletion, and
search.
6
Q
What are graph vertices?
A
Nodes representing entities.
7
Q
What are graph edges?
A
Connections between vertices, representing relationships.
8
Q
A