Answered step by step
Verified Expert Solution
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
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started