Question: In C Programming: ADTs: typedef struct Node{ int item; struct Node* next; }Node; typedef struct List{ Node* head, *tail; int size; }List; Functions: List* addToHead(List*

In C Programming:

ADTs:

typedef struct Node{

int item;

struct Node* next;

}Node;

typedef struct List{

Node* head, *tail;

int size;

}List;

Functions:

List* addToHead(List* uList, int item);

//First, with two given ADTs, implement a function addToHead which adds a new node containing an input integer value to the head of the input linked list, and returns an updated list. Note that you need to update head of the list and increment size after adding a new node.

List* removeHead(List* uList);

//Next, implement a removeHead function that removes the head node from the input linked list and returns the updated linked list. If there is only one node in the list, remove this node and return NULL. You need to update head of the list and decrement size after removing head node. The input for these two functions should be linked list pointer: void printList(List* list);//print updated list void freeList(List* list);//free linked list In main: 1. Create a linked list with 6 nodes using addToHead function. 2. Print out the list as well as the size of the list onto console. 3. Call removeHead function 3 times to remove 3 nodes. 4. Print out the updated list as well as the size of the list after removal. 5. Free the linked list.

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!