1.Easy
In an adjacency list representation of a graph, what is stored for each vertex?
- AA list of its neighbouring vertices
- BA row of V Boolean values
- CThe total number of edges in the graph
- DThe shortest path to every other vertex
2.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
- BTwo copies of the data and one pointer
- CData and a pointer to the next node only
- DData, a pointer to the next node and a pointer to the previous node
3.Easy
What defines a binary tree?
- AEvery node has exactly two children
- BEvery node stores a binary number
- CEvery node has at most two children
- DThe tree has exactly two levels
4.Medium
In a binary min-heap stored in an array (index starting at 0), the children of the node at index i are at:
- Ai + 1 and i + 2
- B2i + 1 and 2i + 2
- C2i and 2i + 1
- Di/2 and i/2 + 1
5.Medium
You have a reference to a node in the middle of a list. In which list can you remove it in O(1)?
- AA dynamic array
- BA doubly linked list
- CA singly linked list
- DA sorted array
6.Medium
An in-order traversal of a binary search tree visits the keys in:
- AInsertion order
- BLevel order
- CAscending sorted order
- DDescending order always
7.Hard
Why might a server choose its hash function at random from a universal family?
- ATo make it very unlikely that an attacker can pick many keys that all collide
- BTo make the hash table sorted
- CTo remove the need to resize the table
- DTo guarantee that no two keys can ever collide, whatever keys an attacker sends
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?
- A60
- B80
- C40
- D70
Answer key
- 1. A · A list of its neighbouring vertices
- 2. D · Data, a pointer to the next node and a pointer to the previous node
- 3. C · Every node has at most two children
- 4. B · 2i + 1 and 2i + 2
- 5. B · A doubly linked list
- 6. C · Ascending sorted order
- 7. A · To make it very unlikely that an attacker can pick many keys that all collide
- 8. A · 60
Full step-by-step solutions: practise this topic on examproblems.com.