Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ program is going to be a binary search program. In your program, you will generate an array that will hold 1000 integers. You will

c++ 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 doesnt 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Administration The Complete Guide To Dba Practices And Procedures

Authors: Craig S. Mullins

2nd Edition

0321822943, 978-0321822949

More Books

Students also viewed these Databases questions

Question

Explain the importance of prioritizing training and HRD needs

Answered: 1 week ago