Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement a Linked Positional List. The linked positional list supports the following functionality: Insert First - Insert's an element at the start of the list.

Implement a Linked Positional List.

The linked positional list supports the following functionality:

  • Insert First - Insert's an element at the start of the list.

  • Insert Last - Insert's an element at the end of the list.

  • Insert Before - Inserts an element at the given position.

  • Remove - Remove the given element.

  • Undo - Undo the action.

Python

The documented positional list interface is in core.py and the class you need to implement is in linked_positional_list.py

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

insert first A header traler insert_before A B remove A header traler 8 undo header 8 trailer undo header trailer undo header K trale aLANGUAGE linked_positional-list 1 core.py def _init__(self): 35 36 37 38 39 40 41 42 43 # The header sentinel self.-header = Node (None) # The trailer sentinel self._trailerNode (None) # Setting the correct previousext self._header.next -self._trailer self-trailer . prev = self.-header 45 46 47 48 49 50 51 52 53 54 def print list(self) Prints the current state of the list; Starting at the header and moving forwards. current = self.headernext list str" while True: - if currentself.trailer: break liststr"".format(current.get_element()) currentcurrent.next 56 57 58 59 60 61 62 63 64 65 return list str def insert first(self, element) # TODO Implement # Create the new element as the first in the list. return None def insert_last(self, element): # TODO Implement LANGUAGE linked-positional-list.! core.py 1 import abc 2 3 4 class Position (metaclass-abc.ABCMeta): 5 6 7 8 @abc.abstractmethod def get_element (self) """Returns the stored element at this position.""" pass 10 12 class PositionalList (metaclass-abc.ABCMeta) 13 14 15 16 17 18 19 20 21 @abc.abstractmethod def print list(self): Runs a pretty print to print the list out. pass @abc.abstractmethod def insert first(self, element) 23 24 25 26 27 28 29 30 31

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

Oracle Database 10g Insider Solutions

Authors: Arun R. Kumar, John Kanagaraj, Richard Stroupe

1st Edition

0672327910, 978-0672327919

Students also viewed these Databases questions

Question

The Nature of Nonverbal Communication

Answered: 1 week ago

Question

Functions of Nonverbal Communication

Answered: 1 week ago

Question

Nonverbal Communication Codes

Answered: 1 week ago