1.Easy
An algorithm's running time is O(n). What is this growth called?
- AQuadratic
- BLinear
- CLogarithmic
- DConstant
2.Easy
What does the worst-case running time of an algorithm describe?
- AThe expected time it takes on a random input of size n
- BThe time it takes on the smallest input
- CThe maximum time it takes over all inputs of size n
- DThe time it takes on a slow computer
3.Easy
How does selection sort work?
- AIt repeatedly finds the minimum of the unsorted part and swaps it to the front
- BIt splits the array in halves and merges them
- CIt repeatedly swaps neighbouring elements that are in the wrong order
- DIt inserts each element into a growing sorted part by shifting
4.Medium
How does Prim's algorithm build a minimum spanning tree?
- AIt grows one tree from a start vertex, adding the cheapest edge that leaves the tree
- BIt runs breadth-first search and keeps the BFS 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
5.Medium
What does the recurrence T(n) = T(n − 1) + O(n) solve to?
- AO(2ⁿ)
- BO(n²)
- CO(n log n)
- DO(n)
6.Medium
What does the Floyd–Warshall algorithm compute, and how fast?
- AShortest paths between all pairs of vertices in O(V³)
- BA minimum spanning tree in O(E log V)
- CA topological order in O(V²)
- DShortest paths from one source vertex to all others in O(V + E)
7.Hard
Which definition of the class P is correct?
- AProblems that need exponential time on every computer
- BProblems that can be solved in parallel
- CProblems whose solutions can be checked but never found in polynomial time
- DDecision problems solvable by a deterministic algorithm in polynomial time
8.Hard
What is the running time of Dijkstra's algorithm with a binary heap on a graph with V vertices and E edges?
- AO(V × E)
- BO(V³)
- CO((V + E) log V)
- DO(V + E)
Answer key
- 1. B · Linear
- 2. C · The maximum time it takes over all inputs of size n
- 3. A · It repeatedly finds the minimum of the unsorted part and swaps it to the front
- 4. A · It grows one tree from a start vertex, adding the cheapest edge that leaves the tree
- 5. B · O(n²)
- 6. A · Shortest paths between all pairs of vertices in O(V³)
- 7. D · Decision problems solvable by a deterministic algorithm in polynomial time
- 8. C · O((V + E) log V)
Full step-by-step solutions: practise this topic on examproblems.com.