1.Easy
What does binary search require of its input?
- AThe array must contain only positive numbers
- BThe array must be sorted
- CThe array must have no more than 1000 elements
- DThe array length must be a power of two
2.Easy
What is the time complexity of depth-first search on a graph stored as adjacency lists?
- AO(V × E)
- BO(E log V)
- CO(V + E)
- DO(V²)
3.Easy
What is recursion?
- AA loop that never ends
- BA type of data structure
- CA function that calls itself on smaller inputs
- DA sorting method
4.Medium
What does the recurrence T(n) = T(n/2) + O(1) solve to?
- AO(log n)
- BO(1)
- CO(n)
- DO(n log n)
5.Medium
With coins of 1, 3 and 4 and an amount of 6, how many coins does the greedy "largest coin first" method use, compared to the optimum?
- AGreedy uses 3 coins; the optimum is 3
- BGreedy uses 2 coins; the optimum is 2
- CGreedy uses 3 coins; the optimum is 2
- DGreedy uses 4 coins; the optimum is 3
6.Medium
How does Prim's algorithm build a minimum spanning tree?
- AIt runs breadth-first search and keeps the BFS tree
- BIt grows one tree from a start vertex, adding the cheapest edge that leaves the tree
- CIt removes the most expensive edge until no cycles remain
- DIt sorts all edges by weight and adds each one unless it would form a cycle in the forest
7.Hard
How is the travelling salesman problem classified?
- AThe decision version is in P but the optimisation version is NP-complete
- BIt is in P because Dijkstra's algorithm solves it by visiting every city once
- CThe decision version is NP-complete and the optimisation version is NP-hard
- DIt is undecidable
8.Hard
Why does binary search not give O(log n) time on a singly linked list?
- AComparisons on linked list nodes are slower
- BReaching the middle element takes O(n) steps, since there is no direct index access
- CBinary search needs at least twice the memory
- DLinked lists cannot be sorted
Answer key
- 1. B · The array must be sorted
- 2. C · O(V + E)
- 3. C · A function that calls itself on smaller inputs
- 4. A · O(log n)
- 5. C · Greedy uses 3 coins; the optimum is 2
- 6. B · It grows one tree from a start vertex, adding the cheapest edge that leaves the tree
- 7. C · The decision version is NP-complete and the optimisation version is NP-hard
- 8. B · Reaching the middle element takes O(n) steps, since there is no direct index access
Full step-by-step solutions: practise this topic on examproblems.com.