In which case(s) does Binary Search perform in O(1) time complexity?

  • When the array is empty
  • When the target element is at the first index of the array
  • When the target element is at the middle of the array
  • When the target element is not present in the array
Binary Search performs in O(1) time complexity when the target element is at the first index of the sorted array. In this case, it can directly access the element and return it. When the array is empty, it still performs in O(1) time complexity as there are no elements to search. In other cases, it performs in O(log n) time complexity, where 'n' is the number of elements in the array.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *