Home
Explore
Exams
Search for anything
Login
Get started
Home
Hash Tables
Hash Tables
0.0
(0)
Rate it
Studied by 0 people
View linked note
Learn
Practice Test
Spaced Repetition
Match
Flashcards
Card Sorting
1/26
There's no tags or description
Looks like no tags are added yet.
Study Analytics
All
Learn
Practice Test
Matching
Spaced Repetition
Name
Mastery
Learn
Test
Matching
Spaced
No study sessions yet.
27 Terms
View all (27)
Star these 27
1
New cards
2
New cards
3
New cards
4
New cards
5
New cards
6
New cards
7
New cards
What is a hash table?
A data structure that maps keys to values using a hash function to compute an index in an array, allowing for fast data retrieval.
8
New cards
What is the average-case time complexity for accessing elements in a hash table?
O(1) — constant time, assuming a good hash function and low load factor.
9
New cards
Name three common collision resolution techniques.
1. Linear probing\n2. Quadratic probing\n3. Separate chaining
10
New cards
What is linear probing?
A collision resolution technique where the algorithm searches sequentially for the next empty slot in the array.
11
New cards
What is clustering in the context of linear probing?
The formation of blocks of occupied slots, which increases the number of probes required during insertion and search.
12
New cards
How does quadratic probing reduce clustering?
It increases the interval between probes using a quadratic function: \\text{step} = i^2, where i is the probe number.
13
New cards
What is double hashing?
A method that uses a second hash function to determine the step size for probing, minimizing clustering and improving distribution.
14
New cards
Why should the hash table size be prime when using double hashing?
To ensure the entire table can be probed and to avoid infinite loops during insertion or search.
15
New cards
What is separate chaining?
A collision resolution method where each array index contains a linked list of entries that hash to the same index.
16
New cards
What is a hash function?
A function that converts a key into an integer index used to store the value in a hash table.
17
New cards
What is the load factor in a hash table?
The ratio of the number of stored elements to the size of the table:\n\\text{Load Factor} = \\frac{\\text{Number of elements}}{\\text{Table size}}
18
New cards
What is the ideal load factor for hash table performance?
Between 0.5 and 0.75 for open addressing techniques.
19
New cards
What is rehashing?
The process of creating a new, larger hash table and reinserting all elements using a new hash function when the table becomes overloaded.
20
New cards
Why is deletion in open addressing difficult?
Removing an element may break the probing sequence for other elements, making them unreachable during search.
21
New cards
How is deletion handled in open addressing?
Elements are marked as deleted (using a special marker), but the slot is not cleared to preserve the probing sequence.
22
New cards
Why are hash tables not suitable for ordered data traversal?
Because hash tables do not store elements in a sorted order—trees are more suitable for that.
23
New cards
When are hash tables the best choice?
When fast search, insertion, and deletion are required, and the data size is relatively stable.
24
New cards
How is modular arithmetic used in hash functions?
It maps large integers into a fixed range by computing the remainder:\n\\text{Index} = \\text{key} \\mod \\text{table size}
25
New cards
What is primary clustering?
A phenomenon in linear probing where groups of occupied cells lead to longer probe sequences.
26
New cards
What is secondary clustering?
Clustering in quadratic probing where different keys follow the same probing sequence, causing virtual clusters.
27
New cards