1.Easy
What does the peek (or top) operation on a stack do?
- AReturns the bottom element of the stack
- BReturns the top element without removing it
- CRemoves all elements from the stack
- DRemoves the top element and returns it
2.Easy
In a singly linked list, each node contains:
- AData and an index
- BData and a reference to the next node
- CData and references to all other nodes
- DOnly data
3.Easy
A graph consists of:
- AKeys and hashes only
- BVertices (nodes) connected by edges
- COnly a root and leaves
- DRows and columns
4.Medium
A node in a binary search tree has a right subtree. Where is its in-order successor?
- AIts right child, always
- BIts parent, always
- CThe leftmost node of its right subtree
- DThe rightmost node of its left subtree
5.Medium
Which data structure does a running program use to keep track of active function calls and their local variables?
- AA binary search tree of frames
- BA hash table of functions
- CThe heap memory queue
- DThe call stack
6.Medium
How long does it take to check whether the edge (u, v) exists using an adjacency matrix?
- AO(V)
- BO(E)
- CO(log V)
- DO(1)
7.Hard
A Bloom filter can answer "is this element in the set?" with:
- APossible false negatives but no false positives
- BAnswers only for numbers
- CExact answers always
- DPossible false positives but no false negatives
8.Hard
Deleting a node with two children from a binary search tree is usually done by:
- AReplacing it with its in-order successor (or predecessor) and deleting that node
- BRemoving the whole subtree
- CRebuilding the subtree below it from scratch and reinserting every key it contained
- DSwapping it with the root
Answer key
- 1. B · Returns the top element without removing it
- 2. B · Data and a reference to the next node
- 3. B · Vertices (nodes) connected by edges
- 4. C · The leftmost node of its right subtree
- 5. D · The call stack
- 6. D · O(1)
- 7. D · Possible false positives but no false negatives
- 8. A · Replacing it with its in-order successor (or predecessor) and deleting that node
Full step-by-step solutions: practise this topic on examproblems.com.