Question: Complete the required missing codes for the program to run correctly. #include #include #include person.h #include list.h using namespace std; List::List ( )

Complete the required missing codes for the program to run correctly.
#include
#include
#include "person.h"
#include "list.h"
using namespace std;
List::List(){
// start index when list is empty
lepos =0;
// initialize the list
for (int i =0; i < MAX_LIST; i++){
plist[i]= Person();
}
}
// add person to system list
void List::add(int id, string name, double salary){
Person p = Person(id, name, salary); // creates person
plist[lepos]= p; // adds person
lepos++; // increment lepos
}
//1. add person to system list at index
void List::addAt(int index, int id, string name, double salary){
// "REMEMBER"
/* You are adding a person to the list at index passed */
/* remove all the comments above/below in this block when you */
/* write codes */
//.................................
//.................................
// Write your codes here
//.................................
//.................................
}
// removes a person from list by id
void List::remove(int id){
// locate the person
for (int i =0; i < lepos; i++){
// if a match is located
if (plist[i].getId()== id){
// once located, shift elements leftward to replace
// the person to be deleted
for (int j = i; j < lepos; j++){
plist[j]= plist[j +1];
}
cout <<"1 person removed successfully. "<< endl;
lepos--; // decrements list
i = lepos; // set to exit loop
}
}
}
//2. selection sort
void List::selectionSort(){
// "REMEMBER"
/* You are sorting people in the list */
/* remove all the comments above/below in this block when you */
/* write codes */
//.................................
//.................................
// Write your codes here
//.................................
//.................................
}
//3. quick sort helper function
void quickSorting(Person person[], int left, int right){
// "REMEMBER"
/* You are sorting people in the list */
/* remove all the comments above/below in this block when you */
/* write codes */
//.................................
//.................................
// Write your codes here
//.................................
//.................................
}
// quick sort root function
void List::quickSort(){// quick sort algorithm
quickSorting(plist,0, lepos -1); // call helper function
}
// searching for the person with largest salary
// using linear search algorithm
Person* List::personLargestSalary(){
// initial maximum salary
int maxindx =0;
// search the next
for (int i =1; i < lepos; i++){
if (plist[i].getSalary()> plist[maxindx].getSalary()){
maxindx = i;
}
}
return &plist[maxindx];
}
// return the people list of the system
Person* List::getList(){
return plist;
}
// returns the size of list showing number of people in list
int List::getLength() const {
return lepos;
}
//4. searches for a person by id using binary search and returns its
// reference if found, otherwise, returns a NULL
Person* List::searchPerson(int id){// binary search
// "REMEMBER"
/* You are searching for a person */
/* remove all the comments above/below in this block when you */
/* write codes */
//.................................
//.................................
// Write your codes here
//.................................
//.................................
}
// prints the list of people
void List::printList(){
Person* ps = plist;
for (int i =0; i < lepos; i++){
cout << ps->personRecord()<< endl;
ps++;
}
/* Use of array directly */
/*
for (int i =0; i < lepos; i++){
cout << plist[i].personRecord()<< endl;
}
*/
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!