Question
What is the best-case time complexity of the binary
search algorithm ?Solution
The best-case time complexity of the binary search algorithm is O(1), which occurs when the target element is found at the middle index on the very first comparison. Binary search divides the array into two halves and compares the middle element with the target. If the middle element matches the target, the search terminates immediately, requiring only one comparison. This efficiency makes binary search a powerful tool for sorted data. Why Other Options Are Incorrect :
- O(n) : This is the time complexity of linear search, where each element is compared sequentially. Binary search is much faster than linear search for sorted data.
- O(log ā” n) : This is the average and worst-case time complexity of binary search, not the best case.
- O(n2) : This is the complexity of algorithms like bubble sort or selection sort, not binary search.
- O(nlog ā” n) : This is the complexity of efficient sorting algorithms like merge sort, not binary search.
The highest Lake of India is?
.__________ is the minimum age to contest a state legislative Council election.
When was the Indus Water Treaty, which featured in news recently, signed by India and Pakistan?
Nuclear explosives devices were tested in India at-
Mahatma Gandhi Sarbat Vikas Yojna was recently launched in the state of
Where is the Dr. Ambedkar Institute of Technology for Handicapped located?
The theme of National Youth Festival observed on 12th January was:
Who composed the patriotic song 'Vijayi Vishwa Tiranga Pyara'?
How many Indian states share border with Myanmar?
Which among the following state won the 8th sub-junior Hockey championship recently held in Assam?