Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The name of the C++ file must be search.cpp Write a program that will read data from a file. The program will allow the user

image text in transcribed

The name of the C++ file must be search.cpp Write a program that will read data from a file. The program will allow the user to specify the filename. Use a loop that will check if the file is opened correctly, otherwise display an error message and allow the user to re-enter a filename until successful. Read the values from the file and store into an integer array. The program should then prompt the user for an integer which will be searched for in the array using binary search. Make sure to include the following A sort function must be called before the binary search. Implement the selection sort function that uses findMin and swap functions as discussed in lecture Include a function called by main to implement the binary search The ordered array produced by the sort function 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 Add a value returning function that computes the median of your data set. (i.e. main function will display the median) -Use showArray function to show elements of the array before sorting and after sorting as required in the program output. The function should display the array values nicely formatted n rows Your program should output The total number of elements read from the file (valid items in the array) The array as read from the file The sorted array The integer being searched for and the location of that integer in the sorted array (or an - - - appropriate message if it is not in the array) -The median of the data set Assume that the maximum number of values in the input file wll not exceed 50. Sample input file: data.dat

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

Guide To Client Server Databases

Authors: Joe Salemi

2nd Edition

1562763105, 978-1562763107

More Books

Students also viewed these Databases questions

Question

6. Does your speech have a clear and logical structure?

Answered: 1 week ago