Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE Type the code. Please provide correct answer!! Question 2 (25 Marks) In this question, we will learn about a variant of linked list called

PLEASE Type the code.

Please provide correct answer!!image text in transcribedimage text in transcribedimage text in transcribed

Question 2 (25 Marks) In this question, we will learn about a variant of linked list called "doubly Linked List". In addition to the "ext pointer pointing to the next node in the list a node in a doubly linked list also contains a pointer "prev" pointing to the previous node in the list 10 4 5 One implementation of the doubly linked List is as follows. #include / Node definition for doubly linked list typedef struct dllnodet int data struct dllnodenext struct doe prev DLLnode.t; Definition of doubly linked list typedef struct DLLnode.t *head DLL.t Creates a doubly linked list DLLt DLLCreate ) DLL-t * ret = malloc ( sizeof ( DLL-t ) ) ; ret->head = NULL return ret; // Appends a DLLnode_t containing the valueinto a DLL.t void DLLAppend (DLLt intlist, int x) // Create DLLnode-t DLLnode.t * newNode = malloc ( size of ( DLLnode-t ) ) ; newNode->data = x newNode->prev = NULL ; newNode-> next = NULL; Point head to new node if list is empty if(int list->head-=NTIL) { in t l i s t->head return new-Node ; = DLLnode.t * temp=intlist->head; while(temp->next != NULL) { temp= ternp->next; // Go To last Node temp-> next = newNode; newNode->prev temp; /Prints the elements of a doubly linked list void DLLPrint (DLLt intlist) DLLnode.t * temp= int list->head; while (temp !=NULL) { printf( "%du" , temp->data ) ; temp = temp->next; printf("n") Part a) Based on the doubly linked list implementation given above, implement a func- tion called "DLLReverse" to reverse a list. For example, if a doubly linked list originally contains the list 14, 5, 7, 7, 9), after calling DLLReverse, the list would become f9, 7, 7, 5, 4). The function prototype is given below // Reverses DLL.t void DLLReverse (DLL.t intlist) Part b) Implement a function called "DLLRemove" to remove any node at a specified index "ind". Just as with C+ arrays, the first element of the list should have an index of 0. Starting at 0, indices go up to one less than the length of the list Your DLLRemove function should give the following message if the user passes in an invalid index: Warning: Invalid index." No other operations should be done if the index is invalid. The function prototype is given below. //Removes the element at indez ind for a DLL.t, anod void DLLRemove(DLLtintlist, int ind)

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

Managing Your Information How To Design And Create A Textual Database On Your Microcomputer

Authors: Tenopir, Carol, Lundeen, Gerald

1st Edition

1555700233, 9781555700232

More Books

Students also viewed these Databases questions

Question

Does it exceed two pages in length?

Answered: 1 week ago

Question

Does it avoid typos and grammatical errors?

Answered: 1 week ago