1.Easy
In a singly linked list, each node contains:
- AData and references to all other nodes
- BOnly data
- CData and a reference to the next node
- DData and an index
2.Easy
What does the peek (or top) operation on a stack do?
- AReturns the bottom element of the stack
- BRemoves all elements from the stack
- CRemoves the top element and returns it
- DReturns the top element without removing it
3.Easy
A graph consists of:
- AKeys and hashes only
- BRows and columns
- CVertices (nodes) connected by edges
- DOnly a root and leaves
4.Medium
A node in a binary search tree has a right subtree. Where is its in-order successor?
- AThe leftmost node of its right subtree
- BIts right child, always
- CIts parent, always
- DThe rightmost node of its left subtree
5.Medium
What is the purpose of a sentinel (dummy) node in a linked list?
- ATo prevent the list from growing beyond a fixed maximum number of nodes
- BTo make the list sorted
- CTo simplify code by removing special cases at the head or tail
- DTo store the number of elements
6.Medium
Why is traversing an array often much faster in practice than traversing a linked list of the same length?
- AArrays use fewer instructions to compare values
- BArray elements are contiguous, so they make good use of the CPU cache
- CArray traversal is O(1) in total, while linked list traversal is O(n)
- DLinked lists always store elements on disk
7.Hard
Why might a server choose its hash function at random from a universal family?
- ATo remove the need to resize the table
- BTo guarantee that no two keys can ever collide, whatever keys an attacker sends
- CTo make the hash table sorted
- DTo make it very unlikely that an attacker can pick many keys that all collide
8.Hard
How does a radix tree (compressed trie) improve on a plain trie?
- AIt sorts the children of each node by frequency
- BIt stores each word in a hash table at the root instead of in separate nodes
- CIt keeps only the first letter of each word
- DIt merges chains of single-child nodes into one edge labelled with a string
Answer key
- 1. C · Data and a reference to the next node
- 2. D · Returns the top element without removing it
- 3. C · Vertices (nodes) connected by edges
- 4. A · The leftmost node of its right subtree
- 5. C · To simplify code by removing special cases at the head or tail
- 6. B · Array elements are contiguous, so they make good use of the CPU cache
- 7. D · To make it very unlikely that an attacker can pick many keys that all collide
- 8. D · It merges chains of single-child nodes into one edge labelled with a string
Full step-by-step solutions: practise this topic on examproblems.com.