Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please refactor iv using vectors rather than arrays. This is sample code : // This program uses a selection sort to arrange an array of
Please refactor iv using vectors rather than arrays.
This is sample code :
// This program uses a selection sort to arrange an array of integers in // ascending order // PLACE YOUR NAME HERE #includeusing namespace std; // function prototypes void selectionSortArray(int[], int); void displayArray(int[], int); const int SIZE = 5; int main() { int values[SIZE] = { 9, 2, 0, 11, 5 }; cout Write a program numbers themselves to be placed in an integer array that holds a maximum of 50 that prompts the user to enter the number of elements and the nts. The program should then p user for an integer which will be searched for in the array using a binary search. Make sure to include the fol- lowing steps along the way: i) A sort routine must be called before the binary search. You may use either the selection sort or the bubble sort. However, the sort must be imple- mented in its own function and not in main. i) Next include a function called by main to implement the binary search. The ordered array produced by the sort should be passed to the search routine which returns the location in the sorted array of the sought value, or -1 if the value is not in the array iii) Add a value returning function that computes the mean of your data set. Recall that the mean is the sum of the data values divided by the number of pieces of data. entered, the array as entered by the user, the sorted array, the integer being searched for, the location of that integer in the sorted array (or an appropriate message if it is not in the array), and the mean of the data set. Your program should output the size of the array ) (Optional) Modify your program so that the data is entered from a file rather than from the keyboard. The first line of the file should be the size r array. The second line should contain the integer for in the data set. Finally, the array elements are to start on the third line. Make sure you separate each array element with a space. The output, as described in ii), should be sent to a file
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started