1.Easy
The depth of a node in a tree is:
- AThe number of edges from the root to that node
- BThe number of nodes in its subtree
- CThe number of children of that node
- DThe number of edges from that node to the deepest leaf
2.Easy
Which structure is typically used to implement a priority queue?
- AA singly linked list without order
- BA heap
- CA string
- DA stack
3.Easy
What does each node in a doubly linked list contain?
- AData and two pointers, one to the next node and one to the node after that
- BData, a pointer to the next node and a pointer to the previous node
- CData and a pointer to the next node only
- DTwo copies of the data and one pointer
4.Medium
What happens when a hash table rehashes after its load factor exceeds a threshold?
- AThe oldest keys are deleted to make room
- BA larger table is allocated and every key is inserted again
- CThe existing keys are sorted in place
- DOnly the colliding keys are moved to a new overflow list at the end of the table
5.Medium
Which data structure is used by depth-first search (iterative version)?
- AA heap
- BA hash table only
- CA queue
- DA stack
6.Medium
In a circular queue stored in an array of capacity n, how is the next position after index i computed?
- A2i + 1
- B(i + 1) mod n
- C(i − 1) mod n
- Di + 1
7.Hard
For a hash table to work correctly, which rule must hash and equality follow?
- ADifferent keys must have different hash values
- BEqual hash values imply equal keys
- CEqual keys must have equal hash values
- DHash values must be prime numbers
8.Hard
What does a splay tree do after each access?
- ARebuilds the whole tree in balanced form
- BRecolours the nodes on the search path
- CMoves the accessed node to a leaf
- DRotates the accessed node up to the root
Answer key
- 1. A · The number of edges from the root to that node
- 2. B · A heap
- 3. B · Data, a pointer to the next node and a pointer to the previous node
- 4. B · A larger table is allocated and every key is inserted again
- 5. D · A stack
- 6. B · (i + 1) mod n
- 7. C · Equal keys must have equal hash values
- 8. D · Rotates the accessed node up to the root
Full step-by-step solutions: practise this topic on examproblems.com.