Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

pls send correct answwr and make it fast only 15 mins please Question 1 A non-arcular, singly linked list Abstract Data Type has a private

image text in transcribed

pls send correct answwr and make it fast only 15 mins please

Question 1 A non-arcular, singly linked list Abstract Data Type has a private Node pointer, called first, which points to the first node of the list. This ADT does not maintain a header pointer to the last node of the list, but it does maintain a vanable size to keep track of the number of nodes in the list. Given a pointer to a node n , assume that values can be read or written to by using the field names n.val and n. next for the value and next fields of the node respectively. Assume that a garbage collector is being used, so nodes do not need to be explicitly freed. Use END for invalid or null address pointer values. (a) delete nth(int n) is a non-recursive method of the ADT that removes node number n from the list and throws an Illegal ArgumentException if no such element exists or f n is less than 0. The first node is numbered 0. Fill in the missing part of the pseudocode for this function below: void delete.nth int n) { // WRITE THE CODE THAT SHOULD BE HERE return 4 [10 marks] (b) Assume that this ADT has two different different methods to delete all the elements from the singly linked ist as follows: void delete all-from-start 1 while (size 0 delete-nth (0) return void delet e-all-from-end NO while (size 0) delete-nch size. return Give the complexities of these two methods in big o notation and explain how you derived them. Write the pseudocode for a much smpler and more efficient method to delete al elements from the list [10 marks)

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

Database Machine Performance Modeling Methodologies And Evaluation Strategies Lncs 257

Authors: Francesca Cesarini ,Silvio Salza

1st Edition

3540179429, 978-3540179429

More Books

Students also viewed these Databases questions

Question

2. What are the different types of networks?

Answered: 1 week ago