Binary Search With Recursion Implementation in C++
Binary search is a fast search algorithm with run-time complexity O(log n). This search algorithm operates on the divide-and-conquer principle. The data collection should be in sorted form for this algorithm to perform effectively.
Binary search compares the middle item in the collection to find a specific item. If a match is found, the item’s index is returned. The item is searched in the sub-array to the left of the middle item if the middle item is greater than the item. Otherwise, look for the item in the sub-array to the right of the middle item. This method is repeated on the sub-array until the subarray’s size is reduced to zero.
All the details discuss with code in the video below:
- Recursion and Backtracking in C++
- Binary Search with Implementation in C++
- Linear Search with Implementation
- Linked List with Implementation in C++
- Python Machine Learning Cookbook