1.Easy
In a graph, what is a cycle?
- AA vertex with no edges
- BA path that starts and ends at the same vertex
- CAn edge with a weight of zero
- DA path that visits every vertex
2.Easy
The depth of a node in a tree is:
- AThe number of children of that node
- BThe number of edges from the root to that node
- CThe number of edges from that node to the deepest leaf
- DThe number of nodes in its subtree
3.Easy
What is the load factor of a hash table?
- AThe number of stored elements divided by the number of buckets
- BThe time needed to load the table from disk
- CThe number of collisions so far
- DThe number of buckets divided by the average length of the keys stored
4.Medium
A road network has 100,000 junctions, each connected to about 4 others. Which representation is most suitable?
- AA binary heap of edges
- BAdjacency matrix
- CA single sorted array of vertices
- DAdjacency list
5.Medium
What happens when a hash table rehashes after its load factor exceeds a threshold?
- AOnly the colliding keys are moved to a new overflow list at the end of the table
- BThe existing keys are sorted in place
- CA larger table is allocated and every key is inserted again
- DThe oldest keys are deleted to make room
6.Medium
How is a new element inserted into a binary heap?
- APlace it at the root and sift it down
- BPlace it at the end of the array and sift it up while it violates the heap property
- CInsert it at its sorted position by shifting all of the larger elements one place right
- DRebuild the whole heap from scratch
7.Hard
Without union by rank or path compression, what is the worst-case cost of a single find in a union-find structure with n elements?
- AO(n)
- BO(1)
- CO(α(n))
- DO(log n)
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
- BTo keep the array sorted
- CTo avoid repeated resizing when pushes and pops alternate near the boundary
- DBecause the memory allocator can only release memory in quarters of a block
Answer key
- 1. B · A path that starts and ends at the same vertex
- 2. B · The number of edges from the root to that node
- 3. A · The number of stored elements divided by the number of buckets
- 4. D · Adjacency list
- 5. C · A larger table is allocated and every key is inserted again
- 6. B · Place it at the end of the array and sift it up while it violates the heap property
- 7. A · O(n)
- 8. C · To avoid repeated resizing when pushes and pops alternate near the boundary
Full step-by-step solutions: practise this topic on examproblems.com.