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.
Fill in the correct option for 27 blank space.
What is the primary purpose of the memory management process known as "compaction"?
Ignoring quantization noise and considering only channel noise in pulse coded modulation system, if signal-to-noise ratio is 10 dB, noise power is 2 dB,...
Fill in the correct option for 24 blank space.
Which approach does BERT use for pre-training?
State true or false
This scheduling algorithm is not ideal for time sharing systems.
Which is best fit for blank space 15?
Which algorithm is commonly used for Part-of-Speech tagging?
Which of the following tools is commonly used for compliance auditing in Unix/Linux environments?
Which of the following protocol should be used for those websites which need login credentials for sending the data?