Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote