Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need the following code written. The first picture is the overall goal of the program. The second and third pictures are of the starter

I need the following code written. The first picture is the overall goal of the program. The second and third pictures are of the starter code, with all of the required doctests to be passed. Thanks!

image text in transcribed

image text in transcribed

image text in transcribed

Goal: [10 pts] During our Live Hands On session (recording available on Canvas), we worked on the implementation of a singly 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: . OrderedLinkedListO0 creates a new ordered list that is empty. It needs no parameters and . addlitem) adds a new Node with value-item to the list making sure that the descending . pop removes and returns the last Node in the list. It needs nothing and returns the value isEmpty0 tests to see whether the list is empty. It needs no parameters and returns a boolean returns nothing. You can assume the items in the list are unique order is preserved. It needs the item and returns nothing. of the Node value. an integer. class Node: def init_(self, value): self.value value self.next None def str (self): return "Node ()) ".format (self.value) repr str class OrderedLinkedList: >>> x=OrderedLinkedList() >>x.pop ) 'List is empty' >>> print (x) Head: Node (8) Tail:Node (-6) List:8 7 3 -6 >>> len (x) >x.pop () >>>print (x) Head: Node (8) Tail:Node (3) List:8 7 3 def init (self): #You can add a count attribute for len self.head None self.tail-None def str (self): - -- temp-self.head out [] while temp: out.append (str (temp.value)) temp-temp.next out-' '.join (out) return ('Head: ()InTail:)InList: ()'.format (self.head, self.tail,out)) repr = str def add (self, value): #write your code here def pop (self): #write your code here def isEmpty (self): #write your code here def len (self): #write your code here

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

Multidimensional Array Data Management In Databases

Authors: Florin Rusu

1st Edition

1638281483, 978-1638281481

More Books

Students also viewed these Databases questions

Question

What Should the Literature Review Do?

Answered: 1 week ago