Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Advances In Databases 11th British National Conference On Databases Bncod 11 Keele Uk July 7 9 1993 Proceedings Lncs 696

Authors: Michael F. Worboys ,Anna F. Grundy

1993rd Edition

3540569219, 978-3540569213

More Books

Students also viewed these Databases questions