Question

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 tvpedef struct shac. szAbc1231d[7]: double dGPA; int iNext: Node; Node nodeMIMAX 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 iFind searchLL(nodeM, iHead, XYZ321, &iprecedes): if (iFind1) printf.(Not found\n); 1. 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 isnt a preceding node, this should be LL NULL



0 0
Add a comment Improve this question Transcribed image text
Answer #1

SOURCE CODE:

#include<stdio.h>
#define MAX_NODES 100
#define LL_NULL -1
typedef struct
{
char szAbc123Id[7];
double dGPA;
int iNext;
}Node;
Node nodeM[MAX_NODES];
int iHead;
int iFind,iBest,iPrecedes;
int comp(char a[],char b[])
{
int i=0;
for(i=0;i<6;i++)
if(a[i]!=b[i])
return -1;
return 0;

}
int searchLL(Node nodeM[],int iHead, char c[7],int *iPrecedes)
{
int i,*j;
int l=0;
i=iHead;
j=LL_NULL;
while(1)
{
if(comp(nodeM[i].szAbc123Id,c)==0)
return i;
else
{
*j=i;
iPrecedes=j;
i=nodeM[i].iNext;
}
if(l==1)
break;
if(nodeM[i].iNext==LL_NULL)
l=1;
}
return LL_NULL;
}
void main()
{

iFind = searchLL(nodeM,iHead,"XYZ321",&iPrecedes);
if(iFind==-1)
printf("Not Found\n");
}

SCREENSHOTS:
Blocks 17.1 Eile Edit Yiew Search Project Build Debug Fortran wmith Iools Tools Plugins DoxyBlocks Settings Help <global> sea

Add a comment
Know the answer?
Add Answer to:
Suppose a linked list (implemented using the array implementation) is ordered by the ABC123 ID and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Suppose a linked list (implemented using pointers) is ordered by the ABC123 ID and a node...

    Suppose a linked list (implemented using pointers) is ordered by the ABC123 ID and a node is represented by the following Node definition: typedef struct char szAbc123Id [7]; double dGPA; Student; tvpedef struct Node // This is different from last week since // student is in the node instead of // directly containing szAbc123Id and dGpa. Student student; struct Node *pNext; Node, Node *pHead; Node *pFind, *pworst, *pPrecedes;

  • C++ help 0.1. An ordered linked list of characters has been constructed using the array-based implementation....

    C++ help 0.1. An ordered linked list of characters has been constructed using the array-based implementation. The following diagram shows the current contents of the array that stores the elements in an alphabetical order in the linked list and an available pool of nodes. Node data next о е м и р first = 5 - п free = 6 о у 1) Write in order the contents (data) of the nodes of the linked list pointed to by first....

  • Using the provided table interface table.h and the sample linked list code linkedList.c, complete an implementation...

    Using the provided table interface table.h and the sample linked list code linkedList.c, complete an implementation of the Table ADT. Make sure that you apply the concepts of design by contract (DbC) to your implementation. Once you have fully implemented the table, create a main.c file that implements a testing framework for your table. Your table implementation must ensure that values inserted are unique, and internally sorted within a linked list. table.h #ifndef _TABLE_H #define _TABLE_H //----------------------------------------------------------------------------- // CONSTANTS AND...

  • In this project, you will be writing an object that implements an ordered linked list with...

    In this project, you will be writing an object that implements an ordered linked list with operator overload support for insertions and deletions. The specification for the list object will be provided upfront and you must design an implementation that supports the provided specification. In addition, you will be given a list of tasks that should be performed. CIS 221 Programming II C++ Programming Project operator overloaded ordered Linked List object Overview In this assignment, the student will write a...

  • 1)Given a Stack implemented with a Linked List, and an O(1) implementation of push and pop,show...

    1)Given a Stack implemented with a Linked List, and an O(1) implementation of push and pop,show the Linked List after the following commands are executed: Stack myStack = new Stack(); myStack.push(20); myStack.push(40); myStack.pop(); myStack.push(60); myStack.push(80); 2)If the same commands were used but the Stack was implemented with an Array with maximum size of 10, show what the array would look like after all these commands are executed. Assume O(1) implementation of push and pop here as well. 3)Given a Queue...

  • I RE: Singly Linked List, Stack, and Queue Implementation Suppose, you have the following Node clas....

    I RE: Singly Linked List, Stack, and Queue Implementation Suppose, you have the following Node clas. public class Node ! int id; Node next: public Node (int id) ( this.id id: Write program codes for the traditional: 1) append int id), prepend(int id), removeFirstNodeO. displayAlINodesO, and findById(int id) operations for a singly linked list 2) pushint id), pop), peek0, displayAllNodes0 operations for a stack 3) enQueue(int id), deQueuel), displayAINodes() operations for a gueue Please make sure that you declare separate...

  • implement a doubly-linked list in C. Each node in the linked list should contain a string,...

    implement a doubly-linked list in C. Each node in the linked list should contain a string, a pointer to the previous node (or NULL), and a pointer to the next node (or NULL). The nodes should be sorted by their strings. struct node_t { char* str; struct node_t* prev; struct node_t* next; } To maintain the doubly-linked list, you should keep a pointer to the head node of the list (or NULL if the list is empty), and a pointer...

  • Programming in C: I am trying to modify this linked list to be doubly linked list....

    Programming in C: I am trying to modify this linked list to be doubly linked list. I’m also trying to add a print in reverse function. I’m really struggling with how to change the insert function to doubly link the nodes without effecting the alphabetical sorting mechanism. Example of desired output: Enter your choice: 1 to insert an element into the list. 2 to delete an element from the list. 3 to end. ? 1 Enter a character: a The...

  • C programming A linked list is a linear data structure that allows us to add and remove items fro...

    c programming A linked list is a linear data structure that allows us to add and remove items from the list very quickly, by simply changing a few pointers. There are many different variations of linked lists. We have studied the doubly-linked, circular, with a dummy-header-node version of a linked list. In the class notes we studied several functions to manipulate a Linked List. For this assignment you must write the code for the following additional linked list functions: addFirst,...

  • Deleting multiples of a given integer from a linked list: #include <stdio.h> #include <stdlib.h> #include <assert.h>...

    Deleting multiples of a given integer from a linked list: #include <stdio.h> #include <stdlib.h> #include <assert.h> #define MAX 10000 typedef struct node_tag { int v; // data struct node_tag * next; // A pointer to this type of struct } node; // Define a type. Easier to use. node * create_node(int v) { node * p = malloc(sizeof(node)); // Allocate memory assert(p != NULL); // you can be nicer // Set the value in the node. p->v = v; p->next...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT