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

Imagine that you have been assigned to implement a simple sequential search on a

ID: 3785397 • Letter: I

Question

Imagine that you have been assigned to implement a simple sequential search on an array. The problem is that you want the search to be as general as possible. This means that you need to support arbitrary record and key types. Describe ways to generalize the search function to support this goal. Consider the possibility that the function will be used multiple times in the same program, on differing record types. Consider the possibility that the function will need to be used on different keys (possibly with the same or different types) of the same record. For example, a student data record might be searched by zip code, by name, by salary, or by GPA.
Data Structures and Algorithm Analysis in C++ by Clifford Shaffer
Imagine that you have been assigned to implement a simple sequential search on an array. The problem is that you want the search to be as general as possible. This means that you need to support arbitrary record and key types. Describe ways to generalize the search function to support this goal. Consider the possibility that the function will be used multiple times in the same program, on differing record types. Consider the possibility that the function will need to be used on different keys (possibly with the same or different types) of the same record. For example, a student data record might be searched by zip code, by name, by salary, or by GPA.
Data Structures and Algorithm Analysis in C++ by Clifford Shaffer

Data Structures and Algorithm Analysis in C++ by Clifford Shaffer

Explanation / Answer

#include #include using namespace std; struct StudentRecord { string ID; float GPA; char name[20]; } student; int i; int totalStudents; int linearSearch (string[],int,string); int main() { int menu; StudentRecord student[] = { {"P1001",78.50,'ABC'}, {"P1002",66.5,'EFG'} }; int totalStudents=0; string id; int j; cout "; cin >> id; break; case 2: cout > id; if(linearSearch(student[].ID,id)) cout