Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Based on the ListNode (provided on iLearn) and LList class in the book, create a linked implementation of the Python list that also supports a

image text in transcribed
image text in transcribed
Based on the ListNode (provided on iLearn) and LList class in the book, create a linked implementation of the Python list that also supports a e(1) append operation by including a tail instance variable. You will need to modify a number of the methods in the book so the tail instance variable is updated appropriately. Your implementation must have the instance variables size, head, and tail. The following invariant is an additional pre and post condition for each self size indicates the number of items in the list if self-size 0, self. head and self .tail are None otherwise self heed is a reference to the first ListNode in list self .tail is a reference to the last ListNode in the list to make the append operation efficient Your class must implement the following methods (more methods on second page) with the same semantics as the built-in Python list. Also write a unit test file test LList.py. def init- (self, seq None) "creates an empty list pre: none post empty list is initialized so it meets the invariant def len (self) returns number of items in the list post: returns number of items in the list def -Liter- (self): 'iteration support using yield keyword post def find self, position) 'private method that returns node that is at location position in the list (0 is first item size-1 is last item) post: returns the ListNode at the specified position in the list" def getitem (self, position) 'return data item at location position pre: 0 position size post: turns data item at the specified position def -setitem. (self, position, value): ''set data itea at location position to value pre 0 position self-size post: sets the data item at the specified position to value'' def --delitem. (self, position): delete item at location position from the list pre: 0 position self size post: the item at the specified position is removed from the list def delete (self, position) Private method to delete item at location position from the list pre: 0 position self. size post: the item at the specified position is removed from the list

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 Internals A Deep Dive Into How Distributed Data Systems Work

Authors: Alex Petrov

1st Edition

1492040347, 978-1492040347

Students also viewed these Databases questions

Question

Where those not participating, encouraged to participate?

Answered: 1 week ago

Question

Were all members comfortable brainstorming in front of each other?

Answered: 1 week ago

Question

4. What will the team agreement contain?

Answered: 1 week ago