Question
SortAndSearch.cpp Objectives: Binary Search and Selection sort You are given a list of 20 names as follows: {Collins, Bill, Smith, Bart, Michalski, Joe, Griffin, Jim,
SortAndSearch.cpp Objectives: Binary Search and Selection sort
You are given a list of 20 names as follows:
{"Collins, Bill", "Smith, Bart", "Michalski, Joe", "Griffin, Jim",
"Sanchez, Manny", "Rubin, Sarah", "Taylor, Tyrone", "Johnson, Jill",
"Allison, Jeff", "Moreno, Juan", "Wolfe, Bill", "Whitman, Jean",
"Moretti, Bella", "Wu, Hong", "Patel, Renee", "Harrison, Rose",
"Smith, Cathy", "Conroy, Pat", "Kelly, Sean", "Holland, Beth"};
Write a program to sort and display the names in alphabet order (use selection sort).
The program prompts the user to enter the name being search (use binary search). The program also makes a correction to upper case the first character of the first and last name (see sample output).
Sample output:
The names in sorted order are:
Allison, Jeff
Collins, Bill
Conroy, Pat
Griffin, Jim
Harrison, Rose
Holland, Beth
Johnson, Jill
Kelly, Sean
Michalski, Joe
Moreno, Juan
Moretti, Bella
Patel, Renee
Rubin, Sarah
Sanchez, Manny
Smith, Bart
Smith, Cathy
Taylor, Tyrone
Whitman, Jean
Wolfe, Bill
Wu, Hong
Type the name to search (Last name, first name):
haRRIson, rOSe
Harrison, Rose was found in the array.
Another name search? (Y/N)y
Type the name to search (Last name, first name):
keLlY, kAY
Kelly, Kay was NOT found in the array.
Another name search? (Y/N)y
// Function prototypes
void displayNames(const string[], int);
Called by main function; passed the array of names and the number of names. Prints the list of names.
void selectionSort(string[], int);
Called by main; passed the array of names and the number of names to sort into alphabetic ascending order.
string upperCaseIt(const string);
Called by main; passed a string being search. Convert the first character of the first and last name of the string passed in to uppercase only.
bool binarySearch(const string[], int, string);
Called by main function; passed the array of strings, the number of strings, and the string being searched for.
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