1.Easy
What is the time complexity of depth-first search on a graph stored as adjacency lists?
- AO(V²)
- BO(V × E)
- CO(E log V)
- DO(V + E)
2.Easy
What is a brute-force algorithm?
- AOne that always uses recursion
- BOne that guesses an answer at random
- COne that tries all possible candidate solutions
- DOne that runs on many processors
3.Easy
What is an algorithm?
- AAny computer program that has a graphical interface
- BA data structure that stores numbers
- CA finite sequence of well-defined steps that solves a problem
- DA programming language designed for writing mathematical formulas
4.Medium
What is the amortised time complexity of appending to a dynamic array that doubles its capacity when full?
- AO(1)
- BO(n²)
- CO(log n)
- DO(n)
5.Medium
How much stack space does a simple recursive factorial function fact(n) = n × fact(n − 1) use?
- AO(n)
- BO(n²)
- CO(log n)
- DO(1)
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 sorts all edges by weight and adds each one unless it would form a cycle in the forest
- DIt removes the most expensive edge until no cycles remain
7.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
- CLinked lists cannot be sorted
- DBinary search needs at least twice the memory
8.Hard
For which knapsack variant does the greedy rule "take items in order of value per weight" always give an optimal answer?
- AThe fractional knapsack, where items may be split
- BNeither variant
- CThe 0/1 knapsack, where items must always be taken whole
- DBoth variants
Answer key
- 1. D · O(V + E)
- 2. C · One that tries all possible candidate solutions
- 3. C · A finite sequence of well-defined steps that solves a problem
- 4. A · O(1)
- 5. A · O(n)
- 6. B · It grows one tree from a start vertex, adding the cheapest edge that leaves the tree
- 7. B · Reaching the middle element takes O(n) steps, since there is no direct index access
- 8. A · The fractional knapsack, where items may be split
Full step-by-step solutions: practise this topic on examproblems.com.