Question: IN C! Starter code included! In the header file you are given, there is a struct called Node that has integer data variable and pointer

IN C! Starter code included!

In the header file you are given, there is a struct called Node that has integer data variable and pointer of type Node, which points to NULL for empty linked list. Below that there are several functions you have to implement in a separate c file.

** FUNCTIONS TO WRITE in SimpleLL.c **

void printList();

This function is used to print the value of the data for each node in a linked list. Using a while loop the code will traverse through the list printing each nodes integer data value as it goes through each node in the list. If the list is empty, print a message. Put a newline after printing each element.

void append(int num);

This function adds a node to the end of the linked lists. If the head is NULL then this means the list is empty. If it is it points the head to the newly created node. Create a temporary node with dynamic memory and initialize the data with numand set node equal to where head is pointing.

void addFront(int num);

This function will add a node to the front of the list. First it will allocate memory for the new node, returning the address of the allocated memory to a local variable. Next it will set the values of the data and next pointer for the new node.

void deleteList();

This function deletes the entire linked list

void removeNode(int num);

This function removes an element with value equal to num from the lists. If there are multiple occurrences of the same element, remove the first occurrence. If the value passed to the function is not found in the list, print a message and return.

int length();

This function calculates the size of the linked listNext we have given you driver.c that demonstrate that all functions that you implemented works. Program take input from user the integer you want to append, add to Back or remove and every time one of the functions called that changes the contents of the linked list, printList to print the entire list,

STARTER CODE in SimpleLL.h:

IN C! Starter code included! In the header file you are given,

STARTER CODE in driver.c:

there is a struct called Node that has integer data variable and

Blessings to those who help

10 1 #ifndef SIMPLELL_H 2 #define SIMPLELL_H 3 4 #include 5 #include 6 7 typedef struct Node 8 { 9 int data; struct Node *next; 11 }nodet; 12 13 node_t* head; 14 15 void printList(); 16 void append(int num); 17 void addFront(int num); 18 void deleteList(); 19 void removeNode(int num); 20 int length(); 21 22 23 24 #endif 25 #include "SimpleLL.h" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 int main() { /*head is a global variable*/ head = NULL; int size =0; removeNode(1); append(2); append(3); addFront(1); append(4); printList(); size length(); printf("size now %d ", size); removeNode (8);| printList(); removeNode(1); printList(); removeNode (4); printList(); deleteList(); printList(); size = length(); printf("size after deletion %d ", size); return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!