Skip to main contentSkip to solution

The average complexity of linear search and binary search are ___ and ____, respectively.

A. O(n)

B. O(n log n)

C. O(log n)

D. O(n*n)

Solution

✅ Correct Option: 4

Linear search checks elements one by one, so on average it makes about n2\dfrac{n}{2} comparisons, which is O(n)O(n).

Binary search halves the sorted search range at every step, so it needs about log⁡2n\log_2 n comparisons, which is O(log⁡n)O(\log n).


Options B and D: O(nlog⁡n)O(n \log n) and O(n2)O(n^2) are typical of sorting algorithms (merge sort and bubble sort respectively), not of searching a list.

Binary search works only on sorted data.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question