Question
// please use c++ and read instructions carefully 1) Write a program that reads 20 names from a file called names.dat and stores them in
// please use c++ and read instructions carefully 1) Write a program that reads 20 names from a file called names.dat and stores them in two different arrays (eg names1, names2). 2) Print the unsorted array of names 3) Now write a function that takes names1 and sorts the names using selection sort. Count how many comparisons are needed to sort the 20 names. Print the sorted array contents and the number of comparisons needed. 4) Next, write a function to sort names2 with the bubblesort routine. Count how many comparisons are needed to sort the array with bubblesort. Print the sorted array and the number of comparisons needed 5) Now write a function that asks the user to enter in a name (one that is stored in the names1 and names files 6) Use the binary search method to look up the name in the sorted array. Display how many comparisons were needed to find the name using the binary search method.
Collins Bill Smith Bart Allen Jim Griffin Jim Stamey Marty Rose Geri Taylor Terri Johnson Jill Allison Jeff Looney Joe Wolfe Bill James Jean Weaver Jim Pore Bob Rutherford Greg Javens Renee Harrison Rose Setzer Cathy Pike Gordon Holland Beth
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