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 FAST Trade Connect e-Platform aims to achieve which of the following goals?
A tailor-made aircraft for Indian specifications and integrating Indian systems and avionics built under license by India's Hindustan Aeronautics Limite...
Who is the Author of Nepali Navel āPhoolangeā ?
Match the following missiles with their specifications:
Who among the following was the tenth Sikh Guru?
Ā The Uttar Pradesh government has tied up with which of the following universities for the construction of Smart City of Knowledge?
Which is the main function of Jawahar Rozgar Yojana?
Which two South African countries have a dispute over an oil-rich Essequibo region ?
What is the theme of World Hindi Day in 2024?
When was the Planning Commission established?Ā