Write a sequential search function to search for a number


a. Modify the insertion sort function to count the number of moves needed to order an array of 100 unique random numbers in the range from 0 to 999 (see Chapter 4 for a discussion of random numbers). Display the array 10 numbers per line before and after the sort. At the end of the program, display the total number of moves needed to sort the array.

b. Write a sequential search function to search for a number in the unsorted array created in 1a. Count the number of comparisons and display the count at the end of the search. Test the search function by searching for the number 101.

c. Improve the sequential search function to search for a number in the sorted array. Count the number of comparisons and display the count at the end of the search. Test the search function by searching for the number 101.

 

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: Write a sequential search function to search for a number
Reference No:- TGS0660979

Expected delivery within 24 Hours