Question: In C++: populate an array of 20 integers with random numbers range from 1-1000. Display these numbers. The program will then sort the numbers into

In C++: populate an array of 20 integers with random numbers range from 1-1000. Display these numbers. The program will then sort the numbers into ascending order using insertion sort. Display the numbers again. The program should then ask the user to input a number, and search to see if the number exists in the array. Your program will need to implement a recursive version of that sequential search algorithm to search for the number.

Use functions to organize your code. You should use the following functions:

  1. A function to populate the array with random numbers between 1 and 1000.

  2. A function to display the numbers on the array.

  3. A function to sort the array in ascending order using insertion sort.

  4. A function that searches for the number. The number to be searched for can be obtained in main and passed to the function.

Example output: In C++: populate an array of 20 integers with random numbers range

lcome to my Recursive Sequential Search Program nsorted.... 501 1) 159 2) 834 3) 906 892 639 ) 19 7) 336 ) 60 640 10) 856 11) 152 12) 565 13) 932 14) 308 15) 177 16) 480 17) 466 18) 710 19) 164 Sorted 19 1) 60 2) 152 3) 159 164 5) 177 308 ) 336 8) 466 ) 480 10) 501 11) 565 12) 639 13) 640 14) 710 15) 834 16) 856 17) 892 18) 906 19) 932 lease Enter the number to be recursively searched in the sorted list: 710 710 is found at index 14 ress any key to continue

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!