What is the average-case time complexity of Binary Search?
- O(1)
- O(log n)
- O(n log n)
- O(n)
The average-case time complexity of Binary Search is O(log n), where 'n' is the number of elements in the array. This is because, on average, Binary Search eliminates half of the remaining elements with each comparison, resulting in a logarithmic growth rate. In the worst-case, it is still O(log n), but in the best-case, it can be O(1) as mentioned in the first question.
Loading...
Related Quiz
- The keyword ________ is used within a constructor to call another constructor in the same class.
- The process of defining a new exception by extending an existing exception class is known as ________.
- Consider a scenario where you need to sort a list of employees based on their age and then return the first employee’s name. How would you achieve this using Stream API?
- The ________ method of DatagramSocket class is used to send a packet to a server.
- Which method is used to start the execution of a thread?