1.Easy
What is the time complexity of finding the largest value in an unsorted array of n numbers?
- AO(1)
- BO(n)
- CO(n log n)
- DO(log n)
2.Easy
What is a brute-force algorithm?
- AOne that tries all possible candidate solutions
- BOne that guesses an answer at random
- COne that runs on many processors
- DOne that always uses recursion
3.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)
4.Medium
Why is the base of a logarithm usually left out in Big O, as in O(log n)?
- AThe base only matters for small n
- BLogarithms with different bases differ only by a constant factor
- CLogarithms are always rounded to integers
- DAll logarithms in computer science have base 10, so it is implied
5.Medium
What does the recurrence T(n) = T(n/2) + O(1) solve to?
- AO(log n)
- BO(n)
- CO(1)
- DO(n log n)
6.Medium
What is the time complexity of: for i = 1 to n: (j = 1; while j < n: j = j × 2)?
- AO(log n)
- BO(n log n)
- CO(n²)
- DO(n)
7.Hard
How does the Bellman–Ford algorithm detect a negative-weight cycle reachable from the source?
- AIt checks whether any edge has a negative weight
- BIt runs Dijkstra's algorithm twice and compares the two distance results
- CAfter V − 1 rounds, it checks whether any edge can still be relaxed
- DIt counts the cycles with depth-first search
8.Hard
Why is the average lookup in a hash table O(1) but the worst case O(n)?
- AMany keys may collide into the same bucket
- BHash functions are slow
- CArrays have O(n) access
- DKeys must be sorted first
Answer key
- 1. B · O(n)
- 2. A · One that tries all possible candidate solutions
- 3. A · O(n)
- 4. B · Logarithms with different bases differ only by a constant factor
- 5. A · O(log n)
- 6. B · O(n log n)
- 7. C · After V − 1 rounds, it checks whether any edge can still be relaxed
- 8. A · Many keys may collide into the same bucket
Full step-by-step solutions: practise this topic on examproblems.com.