1.Easy
What is the time complexity of binary search on a sorted array?
- AO(1)
- BO(log n)
- CO(n log n)
- DO(n)
2.Easy
What is the time complexity of linear search in an unsorted array of n elements (worst case)?
- AO(n²)
- BO(n)
- CO(log n)
- DO(1)
3.Easy
Which notation describes an upper bound on growth?
- ALittle omega
- BBig Theta
- CBig Omega
- DBig O
4.Medium
A function runs one loop of n iterations and then, separately, another loop of n iterations. What is its time complexity?
- AO(n)
- BO(2ⁿ)
- CO(n²)
- DO(log n)
5.Medium
Which statement about a recursive function without a reachable base case is correct?
- AIt runs in O(1) time
- BIt returns 0 automatically
- CThe compiler always turns it into a loop that ends safely
- DIt keeps calling itself until the call stack overflows
6.Medium
Why is the base of a logarithm usually left out in Big O, as in O(log n)?
- ALogarithms are always rounded to integers
- BThe base only matters for small n
- CLogarithms with different bases differ only by a constant factor
- DAll logarithms in computer science have base 10, so it is implied
7.Hard
The halting problem shows that:
- AEvery program eventually halts
- BLoops should be avoided
- CNo algorithm can decide for every program and input whether it halts
- DSome programs run faster on faster computers, so halting depends on hardware
8.Hard
Shortest simple paths can be found in polynomial time. What is known about finding the longest simple path between two vertices in a general graph?
- AIt is undecidable
- BIt can be solved by Dijkstra's algorithm with negated weights
- CIt is always solvable in O(V + E)
- DIt is NP-hard
Answer key
- 1. B · O(log n)
- 2. B · O(n)
- 3. D · Big O
- 4. A · O(n)
- 5. D · It keeps calling itself until the call stack overflows
- 6. C · Logarithms with different bases differ only by a constant factor
- 7. C · No algorithm can decide for every program and input whether it halts
- 8. D · It is NP-hard
Full step-by-step solutions: practise this topic on examproblems.com.