Linked Lists - Course-Student The following data structure, course codes are wri
ID: 3554225 • Letter: L
Question
Linked Lists - Course-Student
The following data structure, course codes are written in array pointer of courses, wheres in student linked list each one
represent the number of students taking the course.
Please write all struct definitions and list of nodes required for your program.
Data File
read from DERS_OGRENCI.TXT text file with the command fgets to read each one of courses as ordered in file in order to add in array pointer. Add each student, linked to the relevant course into the linked list.
DERS_OGRENCI.TXT
(sample file)
MAT 101 267 174 164
Mat202 245241183
Mat303 174 129
Mat404 267183174
Explanation / Answer
/* * Functions related to separate chain hashing */ struct chainNode { int value; chainNode *next; }; chainNode* CreateNewChainNode (int keyValue) { chainNode *newNode; newNode = new (nothrow) chainNode; newNode->value = keyValue; newNode->next = NULL; return newNode; } void InitDynamicArrayList (int tableSize, chainNode **chainListArray) { // create dynamic array of pointers chainListArray = new (nothrow) chainNode*[tableSize]; // allocate each pointer in array for (int i=0; i next == NULL) { // insert new node to front of list, keeping next pointer still set to NULL chainListArray[hashAddress]->next = newNode; } else //else cell is pointing to a list of nodes already { // new node's next pointer will point to former front of linked list newNode->next = chainListArray[hashAddress]->next; // insert new node to front of list chainListArray[hashAddress]->next = newNode; } isInserted = true; coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.