Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python help; Instructions and test cases are posted. Below is what I have for add(item), but it is returning '8' instead of '58' for ordered_ll.tail.

Python help; Instructions and test cases are posted.

Below is what I have for add(item), but it is returning '8' instead of '58' for ordered_ll.tail.

def add(self, value): #write your code here s=self.head maxVal=0 for i in range(self.count): if maxVal value: stop = True else: previous = current current = current.getNext() if previous == None: temp.setNext(self.head) self.head = temp else: temp.setNext(current) previous.setNext(temp) self.count+=1

image text in transcribed

image text in transcribed

Instructions: In class, we worked on the implementation of a linked list. That data structure keeps the elements of the linked list unsorted. Based on the LinkedList code, implement the data structure OrderedLinkedList with the following characteristics: . OrderedLinkedList) creates a new ordered list that is empty. It needs no parameters and returns nothing. Assume the items in the list are unique . add(item) adds a new Node with value-item to the list making sure that the ascending order . delete(item) removes the Node with value-item from the list. It needs the item and modifies . search(item) searches for the Node with value-item in the list. It needs the item and returns is preserved. It needs the item and returns nothing. [40 pts] the list. You can assume the Node is present in the list. [20 pts] a boolean value. [10 pts] . pop) removes and returns the last Node in the list. It needs nothing and returns an the value of the Node. [20 pts] .isEmpty0 tests to see whether the list is empty. It needs no parameters and returns a boolean value. [5 pts] size) returns the number of items in the list. It needs no parameters and returns an integer [5 pts] * NOTE: There is no partial credit for methods that do not work properly. Code will be tested calling all methods and comparing the final list EXAMPLE >>>ordered 11-OrderedLinkedList () >>> ordered 1 1 add ( 8 ) >>> ordered 11.add (7) >>>ordered 11.add (3) >>>ordered 11.add (-6) >>>ordered 11.add (58) >>>ordered 11.add (33) >>> ordered 11.add (1) >>>ordered 11.add (-88)

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_2

Step: 3

blur-text-image_3

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

More Books

Students also viewed these Databases questions

Question

=+ (b) Find an example where u is not countably subadditive.

Answered: 1 week ago

Question

What is meant by 'Wealth Maximization ' ?

Answered: 1 week ago

Question

friendliness and sincerity;

Answered: 1 week ago