Bog o Notation
Bog o Notation
Bog o Notation
Class : BS-SE-3-A
Assignment No: 1
Time complexity of Binary Search is O(log n), where n is the number of elements in the array. It
divides the array in half at each step. Space complexity is O(1) as it uses a constant amount of extra
space.
Worst Case
O(log N)
Auxiliary Space Complexity of Binary Search Algorithm
The auxiliary space complexity of the Binary Search Algorithm is O(1), which means it requires a
constant amount of extra space regardless of the size of the input array. This is because Binary Search
is an iterative algorithm that does not require any additional data structures or recursion that grows
with the input size. Although, we can also implement Binary Search recursively.
Linear Search
Time and Space Complexity Analysis of Linear Search Algorithm
The time complexity of the Linear Search algorithm is O(n), where n is the number of elements in
the array. The space complexity is O(1) as it requires a constant amount of extra space regardless of
the input size.
Worst Case
O(n)
The worst-case will be when the target element is absent from the list or array or is located at the
end of the list. O(n) time complexity results from the necessity to traverse the complete list and
the n comparisons that are required.