1.Easy
What does the peek (or top) operation on a stack do?
- ARemoves all elements from the stack
- BRemoves the top element and returns it
- CReturns the bottom element of the stack
- DReturns the top element without removing it
2.Easy
What is the name of the stack operation that adds an element to the top?
- APeek
- BEnqueue
- CPop
- DPush
3.Easy
What does a map (dictionary) store?
- APairs of equal keys
- BKey-value pairs with unique keys
- COnly values in insertion order
- DValues sorted by size
4.Medium
In a circular queue stored in an array of capacity n, how is the next position after index i computed?
- Ai + 1
- B(i − 1) mod n
- C2i + 1
- D(i + 1) mod n
5.Medium
How is a new element inserted into a binary heap?
- AInsert it at its sorted position by shifting all of the larger elements one place right
- BPlace it at the end of the array and sift it up while it violates the heap property
- CPlace it at the root and sift it down
- DRebuild the whole heap from scratch
6.Medium
How does extract-min work in a binary min-heap?
- ARemove the root and shift all elements one place left
- BSearch all leaves for the new minimum
- CRemove the last element of the array
- DMove the last element to the root and sift it down
7.Hard
Without union by rank or path compression, what is the worst-case cost of a single find in a union-find structure with n elements?
- AO(α(n))
- BO(log n)
- CO(1)
- DO(n)
8.Hard
Why might a server choose its hash function at random from a universal family?
- ATo remove the need to resize the table
- BTo make it very unlikely that an attacker can pick many keys that all collide
- CTo make the hash table sorted
- DTo guarantee that no two keys can ever collide, whatever keys an attacker sends
Answer key
- 1. D · Returns the top element without removing it
- 2. D · Push
- 3. B · Key-value pairs with unique keys
- 4. D · (i + 1) mod n
- 5. B · Place it at the end of the array and sift it up while it violates the heap property
- 6. D · Move the last element to the root and sift it down
- 7. D · O(n)
- 8. B · To make it very unlikely that an attacker can pick many keys that all collide
Full step-by-step solutions: practise this topic on examproblems.com.