[Solved] Exercise Build Working Linked List Program Based Zybooks Chapter 13 C Programming Going Im Q37212133
This exercise is to build out a working linked list programbased on zyBooks Chapter 13 in C programming.
We are going to implement the following utility functions:
- IntNode* CreateNode(int dataInit, IntNode* nextLoc)
- void PrintNodeData(IntNode* thisNode)
- IntNode* FindNode(int searchData, IntNode* startingNode)
- void InsertNodeAfter(int dataInit, IntNode* thisNode)
and these operations:
- Insert x at the end of list
- Insert x at the head of list
- Insert y after item x in the list
- Insert y before item x in the list
- Replace item x with y in the list
- Find & Remove the item x from the list
- Search the list for item x
- Clear the list
- List Empty?
- List full?
- Current List Size
- Print current list contents
Starter Code:
#include <stdio.h>
#include <stdlib.h>
typedef struct IntNode_struct {
int dataVal;
struct IntNode_struct* nextNodePtr;
} IntNode;
IntNode* CreateNode(int dataInit, IntNode* nextLoc) {
return NULL;
}
// Print dataVal
void PrintNodeData(IntNode* thisNode) {
}
IntNode* FindNode(int searchData, IntNode* startingNode) {
return NULL;
}
void InsertNodeAfter(int dataInit, IntNode* thisNode) {
}
void print_menu();
int main(void) {
char cmd;
int newData;
int oldData;
IntNode* headNode = NULL; // Create intNodeobjects
IntNode* tempNode = NULL;
IntNode* lastNode = NULL;
IntNode* tempNode2 = NULL;
int listLength = 0;
headNode = NULL; // empty header node
lastNode = NULL; // pointer to last node in thelist
do
{
print_menu();
scanf(” %c”, &cmd);
switch (cmd)
{
case ‘+’://Insert x at theend
scanf(“%d”,&newData);
printf(“——————n”);
printf(“NOTIMPLEMENTED YET.n”);
printf(“——————n”);
break;
case ‘*’: //insert x at head
scanf(“%d”,&newData);
printf(“——————n”);
printf(“NOTIMPLEMENTED YET.n”);
printf(“——————n”);
break;
case ‘P’: case ‘p’://Printcurrent list contents
printf(“——————n”);
printf(“NOTIMPLEMENTED YET.n”);
printf(“——————n”);
break;
case ‘^’: //Replace item x withy
scanf(“%d %d”,&oldData, &newData);
printf(“——————n”);
printf(“NOTIMPLEMENTED YET.n”);
printf(“——————n”);
break;
case ‘>’: //Insert y afterx
scanf(“%d %d”,&oldData, &newData);
printf(“——————n”);
printf(“NOTIMPLEMENTED YET.n”);
printf(“——————n”);
break;
case ‘<‘: //Insert y beforex
scanf(“%d %d”,&oldData, &newData);
printf(“——————n”);
printf(“NOTIMPLEMENTED YET.n”);
printf(“——————n”);
break;
case ‘-‘://Remove the dataitem
scanf(“%d”,&oldData);
printf(“——————n”);
printf(“NOTIMPLEMENTED YET.n”);
printf(“——————n”);
break;
case ‘C’: case ‘c’://Clear thelist
printf(“——————n”);
printf(“NOTIMPLEMENTED YET.n”);
printf(“——————n”);
break;
case ‘E’: case ‘e’://Emptylist?
printf(“——————n”);
printf(“NOTIMPLEMENTED YET.n”);
printf(“——————n”);
break;
case ‘F’: case ‘f’://Fulllist?
printf(“——————n”);
printf(“NOTIMPLEMENTED YET.n”);
printf(“——————n”);
break;
case ‘L’: case ‘l’://CurrentList Size
printf(“——————n”);
printf(“NOTIMPLEMENTED YET.n”);
printf(“——————n”);
break;
case ‘?’://Search list forx
scanf(“%d”,&oldData);
printf(“——————n”);
printf(“NOTIMPLEMENTED YET.n”);
printf(“——————n”);
break;
case ‘M’: case ‘m’: //Menu
print_menu();
break;
case ‘Q’: case ‘q’: // Quit testprogram
break;
default: // Invalidcommand
printf(“Invalidcommandn”);
break;
}
} while (cmd != ‘Q’ && cmd != ‘q’);
return 0;
}
void print_menu()
{
printf(“Menu…n”);
printf(” M : Menu (displays this message)n”);
printf(” +x : Insert x at the endn”);
printf(” *x : Insert x at the headn”);
printf(” >x y : Insert y after item xn”);
printf(” <x y : Insert y before item xn”);
printf(” ^x y : Replace item x with yn”);
printf(” -x : Find & Remove the item xn”);
printf(” ?x : Search list for xn”);
printf(” C : Clear the listn”);
printf(” E : List Empty?n”);
printf(” F : List full?n”);
printf(” L : Current List Sizen”);
printf(” P : Print current list contentsn”);
printf(” Q : Quit the test programn”);
printf(“Enter Command: “);
}
Expert Answer
Answer to This exercise is to build out a working linked list program based on zyBooks Chapter 13 in C programming. We are going … . . .
OR

