Question: On C++ Description: This program is going to be a binary search program. In your program, you will generate an array that will hold 1000

On C++  On C++ Description: This program is going to be a binary
search program. In your program, you will generate an array that will

Description: This program is going to be a binary search program. In your program, you will generate an array that will hold 1000 integers. You will initialize the array to multiples of 5. For example, index 0 will contain 5, index 1 will contain 10, etc. You will then generate 5 different random numbers that will be in the array and search for them using the binary search algorithm. You will return the index of where the value is. In your search function, print out the indexes of the array that are being search each iteration. (What are begin and end each time through the loop?) You are to use a class called Binary_search to implement this. Your data should be the array and the length of the array. In your default constructor, you should initialize the array and the length. You should have a function called search that takes the target to be found and returns the location in the array or -1 if the value doesn't exist In your main program, you should generate the 5 different random numbers and call the function. (You must make sure that they exist in the array. Hint: This can be done by correctly manipulating the random number generator output.) There will not be any user input for this program. Example output: Searching for 5 Checking indexes 0:999 Checking indexes 0: 499 Checking indexes 0: 249 etc. until found Found at index 0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!