C++ Sorting Orders Modify the following program so that it will search for a an
ID: 645510 • Letter: C
Question
C++
Sorting Orders Modify the following program so that it will search for a an array of strings using a binary search function.
#include
#include
using namespace std;
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;
}
Tip: the array must be sorted before the binary search will work.
Explanation / Answer
#include
#include
using namespace std;
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" };
char search_string;
cout<<"Enter the string u want to search "<<endl;
cin>>search_string;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.