Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Database Systems

Authors: Carlo Zaniolo, Stefano Ceri, Christos Faloutsos, Richard T. Snodgrass, V.S. Subrahmanian, Roberto Zicari

1st Edition

155860443X, 978-1558604438

More Books

Students also viewed these Databases questions