Binary Search Algorithm Principles
Divide and Conquer Technique
Basic principle of Binary Search
Divide the problem into smaller sub-problems
Conquer the sub-problems recursively
Combine the solutions of sub-problems to get the solution of the original problem
Time Complexity of Binary Search
O(log n) in average and worst-case scenarios
Efficient for large data sets
Significantly faster than linear search
Principles of Binary Search Algorithm
Sort the input data before searching
, Use a divide and conquer approach
Compare the search value with the middle element of the current interval
If the search value is equal to the middle element, return its index
If the search value is less than the middle element, repeat the process with the left half
If the search value is greater than the middle element, repeat the process with the right half
If the interval becomes empty, the search value is not in the array
Log N Time Complexity
Time complexity proportional to the logarithm of the input size
Result of dividing the problem into smaller sub-problems at each iteration
Key advantage of the binary search algorithm
Divide and Conquer Technique
Time Complexity of Binary Search
Binary search has a time complexity of O(log N)