1.Easy
A graph consists of:
- ARows and columns
- BKeys and hashes only
- COnly a root and leaves
- DVertices (nodes) connected by edges
2.Easy
What does the peek (or top) operation on a stack do?
- AReturns the bottom element of the stack
- BRemoves the top element and returns it
- CRemoves all elements from the stack
- DReturns the top element without removing it
3.Easy
Which data structure is used to perform a level-order traversal of a tree?
- AQueue
- BHash table
- CPriority queue
- DStack
4.Medium
What happens when a hash table rehashes after its load factor exceeds a threshold?
- AThe existing keys are sorted in place
- BOnly the colliding keys are moved to a new overflow list at the end of the table
- CThe oldest keys are deleted to make room
- DA larger table is allocated and every key is inserted again
5.Medium
Why is traversing an array often much faster in practice than traversing a linked list of the same length?
- AArray elements are contiguous, so they make good use of the CPU cache
- BArrays use fewer instructions to compare values
- CLinked lists always store elements on disk
- DArray traversal is O(1) in total, while linked list traversal is O(n)
6.Medium
What is the cost of inserting an element in the middle of an array of n elements?
- AO(n²), because each element moves n times
- BO(n), because later elements must shift
- CO(log n), because of binary search
- DO(1), because the index is known
7.Hard
A segment tree is typically used to:
- ASort strings alphabetically by storing each prefix in a separate tree node
- BAnswer range queries (such as range sums) and updates in O(log n)
- CStore a graph's edges
- DImplement a stack
8.Hard
In the BST with root 50, left subtree 30 (children 20, 40) and right subtree 70 (children 60, 80), the root is deleted using the in-order successor. Which key becomes the new root?
- A40
- B60
- C80
- D70
Answer key
- 1. D · Vertices (nodes) connected by edges
- 2. D · Returns the top element without removing it
- 3. A · Queue
- 4. D · A larger table is allocated and every key is inserted again
- 5. A · Array elements are contiguous, so they make good use of the CPU cache
- 6. B · O(n), because later elements must shift
- 7. B · Answer range queries (such as range sums) and updates in O(log n)
- 8. B · 60
Full step-by-step solutions: practise this topic on examproblems.com.