Question: Binary search Write a program in C that has a function with a recursive implementation of binary search . Answer the following questions to help
Binary search
Write a program in C that has a function with a recursive implementation of binary search.
Answer the following questions to help you figure out the solution
What is(are) the smaller sub-problem(s)
What is(are) the base case(s)
How would you computing the solution of the original problem based on the solution of the smaller sub-problem(s)
Your program should first read a sorted int array as input from a file. The path to this file is provided as a command line argument. The program then proceeds to ask the user for search key and prints the location of the search key in the array if the element is found. Otherwise, prints "Element not found!".
Your program should have a function that implements binary search algorithm for looking up an element in an array and returns the location of the first occurrence of the searchKey in the input array, if the searchKey is found in the input array. Otherwise, it should return -1.
Example:
Enter the length of the array: 25
Enter the array:
2 4 5 7 10 12 14 18 21 23 25 26 29 30 32 35 45 51 56 62 64 66 79 80 83
Enter the key to search: 23
23 is in the position 9.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
