Data Structures & AlgorithmsModerateProduct company OA · Infosys pattern
A hash map starts with capacity 16 and doubles its capacity whenever the number of keys EXCEEDS 0.75 × capacity. What is its capacity after 25 distinct keys have been inserted?
- A. 32
- B. 128
- C. 64
- D. 48
Correct answer: C. 64
The 13th key exceeds 12 = 0.75 × 16 → capacity 32 (threshold 24). The 25th key exceeds 24 → capacity 64. Stopping at 32 forgets the second resize; 25 keys in 32 slots would be a load factor of 0.78.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- Bubble sort (each pass compares adjacent pairs left to right and swaps if out of order) runs on [6, 2, 9, 1, 5]. What is the array after…
- The array [1, 2, 3, 4, 5, 6] is first rotated RIGHT by 2 positions and then rotated LEFT by 5 positions. What is the result?
- What is the longest common prefix of the strings interview, internet, interval and intern?
- The first k = 4 elements of the queue 1, 2, 3, 4, 5, 6 (front first) are reversed using a stack: dequeue 4 items onto the stack, pop them…
- k sorted lists contain N elements in total. They are merged into one sorted list by repeatedly taking the smallest head from a min-heap…
- A deque of indices gives the MINIMUM of every window of size 3 in [4, 2, 12, 3, 8, 1, 7]. What are the window minima?