Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Suppose a linked list (implemented using the array implementation) is ordered by the ABC123 ID and a node is represented by the following Node definition:

Suppose a linked list (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

typedef struct

{

char szAbc123Id[7];

double dGPA;

int iNext;

} Node;

Node nodeM[MAX_NODES];

int iHead;

int iFind, iBest, iPrecedes;

// assume the linked list has been populated with values and

// iHead points to the first node in that array.

// practice problem #1- sample invocation

printHighGPAs(nodeM, iHead);

// practice problem #2- sample invocation

iFind = searchLL(nodeM, iHead, "XYZ321", &iPrecedes);

if (iFind == -1)

printf("Not found ");

// practice problem #3 - sample invocation

iBest = getHighestStudent(nodeM, iHead);

if (iBest == -1)

printf("list is empty ");

else

printf("Best student is %s ", nodeM[iBest].szAbc123Id);

Practice Problems

1. Show the function, printHighGPAs(Node nodeM[], int iHead), which prints the ABC123 ID and GPA for students having a GPA >= 3.5 of students in the linked list that begins at iHead.

2. Modify the searchLL function from class to be passed an ABC123 ID and find the specified student in the linked list. If it is found, return the subscript to that student. If it is not found, return LL_NULL. Also, return (via the parameter list) the subscript to the node that precedes that node. If there isn't a preceding node, this should be LL_NULL.

3. 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.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions