Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3) [38 points] Linked List You may only use the struct and the functions below If you want to use any other function, you need

image text in transcribed image text in transcribed

3) [38 points] Linked List You may only use the struct and the functions below If you want to use any other function, you need to implement it. // A node in linked list struct node ( int data; struct node* next; typedef struct node node_ti /Linked list typedef struct node_t* head; // pointer to the head of the list LL t; // Adds a new element to the head of a list void LL add to head (LL t* 1ist, int value) /Removes the first element from a list nt LL remove from head (LL t* list); //Returns true if the list is empty, and returns false otherwise b1 LL 1s empty (LL t* list); //frees the linked list void LL free (LL t* list) (a) [15 points] Write a function that gets a linked list, and reverses it. For example, if the input is 1 2-3- 4, then after applying the function, the list will be 4- 3--2-1 void LL reverse (LL t* list) [4 points] What is the running time of your function? (b) [15 points] Write a function that gets a linked list and a parameter k, and removes the k'th element from the end of the list. (For k-0, we need to remove the last element) For example, if the input list is 1-2--3-4- 5, and k-2, then after applying the function, the list will be 1 2 4 5 If k >= length of the list, then the list remains the same

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

Repairing And Querying Databases Under Aggregate Constraints

Authors: Sergio Flesca ,Filippo Furfaro ,Francesco Parisi

2011th Edition

146141640X, 978-1461416401

More Books

Students also viewed these Databases questions

Question

Describe the events that occur during fertilization.

Answered: 1 week ago