Which of the following represents logarithmic time complexity?
Options
- A. O(N)
- B. O(log N)
- C. O(N2)
- D. More than one of the above
- E. None of the above
Quiz Practice:
B. O(log N)
O(log N) is called logarithmic time complexity. It commonly occurs when an algorithm repeatedly reduces the problem size by a constant factor, such as dividing it by two. Binary search is a classic example: each comparison eliminates approximately half of the remaining elements. Logarithmic algorithms are highly efficient for large inputs because the number of operations grows slowly compared with linear or quadratic algorithms.