Question 11
EasyWhat is quadratic probing?
- A.
Squaring the key before hashing
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Data Structures and Algorithms
What is quadratic probing?
Squaring the key before hashing
Using two tables
Probing every slot in order
After a collision, trying slots 1², 2², 3², … positions away from the original slot
Sign up free to see the answer and a step-by-step explanation.
Which Java class is a hash-table implementation of the Map interface?
TreeMap
ArrayList
LinkedList
HashMap
Sign up free to see the answer and a step-by-step explanation.
Which C++ STL container is hash-based?
vector
unordered_map
list
map
Sign up free to see the answer and a step-by-step explanation.
Does a hash set allow duplicate elements?
Only two copies
No; each element appears at most once
Only duplicates of numbers
Yes, any number of times
Sign up free to see the answer and a step-by-step explanation.
What does a hash map store?
Only numbers
Key–value pairs
Only values in sorted order
Only keys
Sign up free to see the answer and a step-by-step explanation.
With a hash map, how fast can you find whether two numbers in an array add up to a target?
O(n²)
O(1)
O(n log n)
O(n) on average
Sign up free to see the answer and a step-by-step explanation.
A hash table of size 7 uses h(k) = k mod 7. In which slot does the key 50 go?
7
0
1
50
Sign up free to see the answer and a step-by-step explanation.
Keys are placed with h(k) = k mod 10. Which slot does the key 15 land in?
15
0
1
5
Sign up free to see the answer and a step-by-step explanation.
Which structure is most efficient for counting how often each word appears in a large text?
A hash map from word to count
A sorted array searched linearly
A stack
A queue
Sign up free to see the answer and a step-by-step explanation.
What is the output of this code?
d = {'a': 1}
d['b'] = 2
d['a'] = 5
print(len(d))
5
3
Sign up free to see the answer and a step-by-step explanation.
2
1