What is the time complexity of binary search on a sorted array?
- O(1)
- O(log n)
- O(n)
- O(n^2)
The time complexity of the binary search algorithm on a sorted array is O(log n), where 'n' is the number of elements in the array. This logarithmic time complexity makes binary search highly efficient for large datasets.
Loading...
Related Quiz
- The time complexity of linear search in the worst-case scenario is _______.
- Can topological sorting be applied to graphs with weighted edges? Explain.
- What type of data structure is a binary tree?
- A doubly linked list contains nodes that have _______ pointers.
- How does the concept of recursion relate to the implementation of binary search?