Question
Which of the following is NOT true about binary search ?
Solution
Binary search is an efficient searching algorithm designed to find an element in a sorted array. Its time complexity in the worst case is O(logn), not O(n), making option 2 incorrect. The process involves dividing the search space into two halves after every comparison. Binary search operates under the condition that the array is sorted. If not, it leads to undefined behavior or incorrect results. Option 1 is correct because the algorithm strictly requires a sorted array. The halving of the search space ensures logarithmic complexity, and this property is central to binary search, making option 3 valid. Binary search can be implemented both iteratively and recursively, which provides flexibility in practical applications, making option 4 correct. Additionally, the algorithm can handle various data types, including strings, as long as the data is comparable, confirming the correctness of option 5. The claim in option 2, that the time complexity is O(n), reflects a misunderstanding of how binary search reduces the problem size. O(n) is the complexity of linear search, which scans every element. Binary search leverages the sorted nature of data to skip unnecessary comparisons, making it much faster. Even in the worst case, where the element might not exist, the logarithmic reduction persists. Why Other Options Are Incorrect? 1. Requires a sorted array: True, as binary search is based on comparisons against the middle element in a sorted order. Unsorted arrays invalidate the algorithm's assumptions. 2.Halves search space after each comparison: Accurate. This halving mechanism is the foundation of binary search, reducing complexity to O(logn). 3. Implemented using recursion or iteration: Correct, as both methods achieve the same goal with slight differences in implementation details. 4. Works for numerical and string data: Valid, as long as the data has a natural ordering or a comparator function is defined.
The 'Rovers Cup' is associated with which sport?
Consider the following statement about PM Gati Shakti Scheme?
I. It was launched with the aim of coordinated planning and execution of infrast...
Ministry of Rural Development (GoI) has awarded ___________ with ‘National Award for Outstanding Performance for FY 2020-21’, for its best p...
What is the main focus of the 'Viksit Bharat @2047' vision document being finalized by NITI Aayog?
Which country’s president visited India to enhance defense and energy ties?
Which small finance bank has launched its groundbreaking customer service 24x7 via Video Banking that provides a virtual platform where customers can co...
Which country contributed 50% of total Foreign Direct Investment (FDI) in India in Q2 FY2024-25?
What is the increased minimum capital requirement set by the Reserve Bank for small finance banks (SFBs)?
Which of the following Indian art styles was featured in the "Hunar" exhibition in Dubai?
How many medals did India win at the Asian Under-18 Athletics Championships 2025?