Question: Using c++ Q1. Implementation of a Function Template Write a simple global function template for function binarySearch, which looks for a particular item by comparing

Using c++ Q1. Implementation of a Function Template Write a simple global function template for function binarySearch, which looks for a particular item by comparing the middle most item of the collection. If a match occurs, then the index of item is returned. If the middle item is greater than the item, then the item is searched in the sub-array to the left of the middle item. Otherwise, the item is searched for in the sub-array to the right of the middle item. This process continues on the sub-array as well until the size of the subarray reduces to zero. Test this function template in a main program that calls binarySearch for int, double, char and string. NOTE: For a binary search to work, it is mandatory for the target array to be sorted EXAMPLE: Searching an integer by using binary search. Binary Search 12 16 23 38 56 72 91 2 3 e 21 58 12 5 23 7 38 56 16 72 91 2 5 12 16 23 38 56 72 91 2 5 8 12 16 23 38 56 72 91
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
