Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

// 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

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

Database And Expert Systems Applications 15th International Conference Dexa 2004 Zaragoza Spain August 30 September 3 2004 Proceedings Lncs 3180

Authors: Fernando Galindo ,Makoto Takizawa ,Roland Traunmuller

2004th Edition

3540229361, 978-3540229360

More Books

Students also viewed these Databases questions