1.Easy
A graph consists of:
- ARows and columns
- BOnly a root and leaves
- CVertices (nodes) connected by edges
- DKeys and hashes only
2.Easy
What is a directed graph?
- AA graph whose edges all have weights
- BA graph that has no cycles
- CA graph whose edges have a direction from one vertex to another
- DA graph in which every pair of distinct vertices is joined by an edge
3.Easy
What is the main difference between a static array and a dynamic array?
- AA dynamic array stores its elements in linked nodes so it can grow one at a time
- BA static array allows slower index access
- CA dynamic array can grow by moving to a larger block of memory
- DA static array can only store numbers
4.Medium
A queue is implemented with two stacks: push onto an "in" stack, and pop from an "out" stack, refilling it from "in" when empty. What is the amortised cost per operation?
- AO(log n)
- BO(1)
- CO(n²)
- DO(n)
5.Medium
Which data structure is used to check whether the brackets in "{[()]}" are balanced?
- AA stack
- BA queue
- CA binary search tree
- DA hash table
6.Medium
How do you find the minimum key in a binary search tree?
- ALook at the root only
- BFollow right children from the root until there is no right child
- CFollow left children from the root until there is no left child
- DVisit every leaf and compare them
7.Hard
The union-find (disjoint set) structure with union by rank and path compression has an amortised cost per operation of:
- AO(n²)
- BO(log n) exactly
- CO(n)
- DO(α(n)), the inverse Ackermann function, which is practically constant
8.Hard
Which problem of linear probing does double hashing mainly reduce?
- AThe need for a hash function
- BThe O(n) cost of reading a key's value
- CPrimary clustering, where long runs of occupied slots form
- DThe need to store keys in the table
Answer key
- 1. C · Vertices (nodes) connected by edges
- 2. C · A graph whose edges have a direction from one vertex to another
- 3. C · A dynamic array can grow by moving to a larger block of memory
- 4. B · O(1)
- 5. A · A stack
- 6. C · Follow left children from the root until there is no left child
- 7. D · O(α(n)), the inverse Ackermann function, which is practically constant
- 8. C · Primary clustering, where long runs of occupied slots form
Full step-by-step solutions: practise this topic on examproblems.com.