Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Below are the node_struct, link, list_struct and list as defined in class and in hw3: typedef struct node_struct * link; struct node_struct { int item;

Below are the node_struct, link, list_struct and list as defined in class and in hw3: typedef struct node_struct * link;

struct node_struct {

int item;

link next;

};

typedef struct list_struct * list;

struct list_struct {

link first;

int length;

};

a) (15 pts) Write a function that swaps the first and last node in a list. If there are not enough nodes, it does not do anything to the list. You have to update the links yourself. DO NOT call any insert or remove functions to do any of the work for you. void swapFirstLast(list L) { b) (8 pts) Make a drawing of a list with 5 (five) nodes and show how the links are updated as done in class. Label each arrow update with the line number that did it. c) (3 pts) What is the complexity of your function? Justify your answer. (You can show to the side of the code) d) (4 pts) If your function fails or crashes for certain inputs, give those inputs and clearly indicate the line with the problem (use line numbers or write the test cases as a comment on that line of code).

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

Case Studies In Business Data Bases

Authors: James Bradley

1st Edition

0030141346, 978-0030141348

More Books

Students also viewed these Databases questions

Question

Solve the following 1,4 3 2TT 5x- 1+ (15 x) dx 5X

Answered: 1 week ago