1.Easy
Accessing an element by index in an array takes:
- AO(n)
- BO(log n)
- CO(1)
- DO(n²)
2.Easy
Which sorting algorithm repeatedly swaps adjacent elements that are in the wrong order?
- AQuicksort
- BBubble sort
- CMerge sort
- DHeap sort
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
A greedy algorithm:
- AUses only recursion
- BMakes the locally best choice at each step
- CAlways gives the optimal solution
- DTries every possible solution
5.Medium
Is it correct to say that an O(n²) algorithm is also O(n³)?
- AYes, but only if n is smaller than 100
- BNo, because n³ is smaller than n² for large n
- CYes, because Big O is an upper bound and n² grows no faster than n³
- DNo, because Big O must always state the exact growth rate of the function
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
- BAll logarithms in computer science have base 10, so it is implied
- CLogarithms with different bases differ only by a constant factor
- DThe base only matters for small n
7.Hard
Taking both endpoints of every edge in a maximal matching gives a vertex cover. How good is this cover?
- AOf unknown quality compared to the optimum
- BAt most twice the size of a minimum vertex cover
- CAt most log n times the minimum
- DAlways a minimum vertex cover
8.Hard
Which bound is correct for log(n!)?
- AΘ(log n)
- BΘ(n log n)
- CΘ(n)
- DΘ(n²)
Answer key
- 1. C · O(1)
- 2. B · Bubble sort
- 3. A · O(n)
- 4. B · Makes the locally best choice at each step
- 5. C · Yes, because Big O is an upper bound and n² grows no faster than n³
- 6. C · Logarithms with different bases differ only by a constant factor
- 7. B · At most twice the size of a minimum vertex cover
- 8. B · Θ(n log n)
Full step-by-step solutions: practise this topic on examproblems.com.