Short Note On binary search and binary tree
Binary search is a searching algorithm used to find the position of a target value within a sorted array. Here's how it works: Start by setting the lower bound low to 0 and the upper bound high to the length of the array minus 1. Calculate the middle index mid as the average of low and high, rounded down to the nearest integer. Compare the target value with the value at the middle index in the array: If they're equal, the target value has been found. Return the middle index. If the target value is less than the middle value, set high to mid - 1 and repeat step 2. If the target value is greater than the middle value, set low to mid + 1 and repeat step 2. If the target value is not found after iterating through the array, return -1 to indicate that the value was not found. Here's the pseudocode for this algorithm: function binarySearch(array, target): low = 0 high = array.length - 1 while low <= high: mid = floor((low + high) / 2) if array[mid