1.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
- CTwo copies of the data and one pointer
- DData and a pointer to the next node only
2.Easy
In a graph, what is a cycle?
- AA path that starts and ends at the same vertex
- BAn edge with a weight of zero
- CA path that visits every vertex
- DA vertex with no edges
3.Easy
What is the root of a tree?
- AThe top node with no parent
- BAny node in the middle
- CThe node with the largest value
- DA node with no children
4.Medium
In a hash table using open addressing, what is the maximum possible load factor?
- A0.5
- B1
- CThere is no maximum
- D2
5.Medium
A hash table of size 7 uses h(k) = k mod 7 and linear probing. After inserting 10, where is 17 stored?
- AIndex 0
- BIndex 6
- CIndex 4
- DIndex 3
6.Medium
Which data structure is used to check whether the brackets in "{[()]}" are balanced?
- AA binary search tree
- BA stack
- CA hash table
- DA queue
7.Hard
In Kruskal's minimum spanning tree algorithm, what is the union-find structure used for?
- AChecking whether an edge's two endpoints are already connected
- BChoosing the starting vertex
- CSorting the edges by weight
- DStoring each vertex's current distance from the source during the search
8.Hard
A dynamic array doubles when full. Why do many implementations shrink it only when it is one quarter full, not half full?
- ABecause halving at one half would lose elements
- BBecause the memory allocator can only release memory in quarters of a block
- CTo keep the array sorted
- DTo avoid repeated resizing when pushes and pops alternate near the boundary
Answer key
- 1. B · Data, a pointer to the next node and a pointer to the previous node
- 2. A · A path that starts and ends at the same vertex
- 3. A · The top node with no parent
- 4. B · 1
- 5. C · Index 4
- 6. B · A stack
- 7. A · Checking whether an edge's two endpoints are already connected
- 8. D · To avoid repeated resizing when pushes and pops alternate near the boundary
Full step-by-step solutions: practise this topic on examproblems.com.