Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Binary String Search Modify the selectionSort function presented in this chapter so it sorts an array of strings instead of an array of ints. Then

Binary String Search

Modify the selectionSort function presented in this chapter so it sorts an array of strings instead of an array of ints. Then modify and use the binarySearch function to find a specific element in the array. Test the function with this driver program:

#include  #include  using namespace std; // Function prototypes void selectionSort(string values[], int size); void displayArray(string values[], int size); int binarySearch(string values[], int size, string value); int main() { const int NUM_NAMES = 20; string names[NUM_NAMES] = { "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" }; // Insert your code to complete this program return 0; }

Note: Your program MUST include the three functions prototyped above and must use them appropriately. The main procedural code should do little more than call the various functions as needed. It will also need to preform a bit of I/O (ask the user for the name to find and display the result).

The output should look something like this: Here are the names sorted: -------------------------- Allen, Jim Allison, Jeff Collins, Bill Griffin, Jim Harrison, Rose Holland, Beth James, Jean Javens, Renee Johnson, Jill Looney, Joe Pike, Gordon Pore, Bob Rose, Geri Rutherford, Greg Setzer, Cathy Smith, Bart Stamey, Marty Taylor, Terri Weaver, Jim Wolfe, Bill Enter a name to search for: Baggins, Frodo That names does not exist in the array. Running the program again: ... Weaver, Jim Wolfe, Bill Enter a name to search for: Pore, Bob That name is found at element 11 in the array.

Compile, run, and test your program. Make sure there are no errors and it functions properly. You can hit F5 to compile and run the program. Your program must run without errors to get full credit! Upload (attach!) your cpp file here for grading. It must be named correctly and saved as a readable cpp file with the proper extension.

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

Learning PostgreSQL

Authors: Salahaldin Juba, Achim Vannahme, Andrey Volkov

1st Edition

178398919X, 9781783989195

More Books

Students also viewed these Databases questions

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago