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

implemented using the array implementation) is ordered by the ABC123 ID and a no

ID: 3726364 • Letter: I

Question

implemented using the array implementation) is ordered by the ABC123 ID and a node is represented by the following Node definition: #define MAX NODES 100 typsdef strust shar szAbc123Id[7]; double dGPA int iNext Node Node nodeMIMAX NODES]; int iHead ánt iFind, iBest, iPcecedes // assume the linked list has been populated with values and // iHead points to the first node in that array. // practice problem #1|-sample invocation iBest getHigheststudent (nodell, iHead); if (iBest1) printf("list is empty "); else erintfl."Best student is %s ", nodentiBest].szAbc1231d); 1. Show code for the function, getHighestStudent, which is passed an array of nodes and iHead. It returns a subscript of the node for the student with the highest GPA. Return -1 if there aren't any nodes in the linked list.

Explanation / Answer

int getHighestStudent(Node nodeM[],int iHead)
{
int p=0,position=0;
double max;
if(iHead==-1)
return -1;
/* if list is not empty */
else
{
p=iHead;
max=nodeM[p].dGPA;
for(p=1;nodeM[p].next!=-1;++p)
{
if(max<nodeM[p].dGPA)
{
max=nodeM[p].dGPA;
position=p;
}
}
}
return position;
}