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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started