Question: Complete the missing codes for this cpp file: #include #include #include person.h #include list.h using namespace std; List::List ( ) { / /
Complete the missing codes for this cpp file:
#include
#include
#include "person.h
#include "list.h
using namespace std;
List::List
start index when list is empty
lepos ;
initialize the list
for int i ; i MAXLIST; i
plisti Person;
add person to system list
void List::addint id string name, double salary
Person p Personid name, salary; creates person
plistlepos p; adds person
lepos; increment lepos
add person to system list at index
void List::addAtint index, int id string name, double salary
"REMEMBER"
You are adding a person to the list at index passed
remove all the comments abovebelow in this block when you
write codes
Write your codes here
iflepos MAXLIST && index && index MAXLIST
forint i lepos; i && i index; i
plistlepos plistlepos;
Person newPid name, salary; create person object
plistindex newP; initialise object to the list
lepos;
removes a person from list by id
void List::removeint id
locate the person
for int i ; i lepos; i
if a match is located
if plistigetId id
once located, shift elements leftward to replace
the person to be deleted
for int j i; j lepos; j
plistj plistj ;
cout person removed successfully. endl;
lepos; decrements list
i lepos; set to exit loop
selection sort
void List::selectionSort
"REMEMBER"
You are sorting people in the list
remove all the comments abovebelow in this block when you
write codes
Write your codes here
int i j minIndex;
for i ; i MAXLIST ; i
minIndex i;
for j i ; j MAXLIST; j
Compare based on some criteria eg ID
if plistjgetId plistminIndexgetId
minIndex j;
Swap the Person objects
if minIndex i
Person temp plisti;
plisti plistminIndex;
plistminIndex temp;
quick sort helper function
void quickSortingPerson person int left, int right
"REMEMBER"
You are sorting people in the list
remove all the comments abovebelow in this block when you
write codes
Write your codes here
int low left, high right, temp;
Person pivot personlow high;
whilelow high
whilepersonlow pivot
low;
whilepersonhigh pivot
high;
iflow high
swappersonlow personhigh;
low;
high;
;
quick sort root function
void List::quickSort quick sort algorithm
quickSortingplist lepos ; call helper function
searching for the person with largest salary
using linear search algorithm
Person List::personLargestSalary
initial maximum salary
int maxindx ;
search the next
for int i ; i lepos; i
if plistigetSalary plistmaxindxgetSalary
maxindx i;
return &plistmaxindx;
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;
searches for a person by id using binary search and returns its
reference if found, otherwise, returns a NULL
Person List::searchPersonint id binary search
"REMEMBER"
You are searching for a person
remove all the comments abovebelow in this block when you
write codes
Write your codes here
int size sizeofplistsizeofplist;
int low high size ;
int mid low high;
whilemid high
ifplistmidgetId id
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
