Question: Implementing a Linked Positional List I've written other functions, how to do the undo() in python def __init__(self): # The header sentinel self._header = Node(None)

Implementing a Linked Positional List

Implementing a Linked Positional List I've written other functions, how to do

I've written other functions, how to do the undo() in python

def __init__(self): # The header sentinel self._header = Node(None) # The trailer sentinel self._trailer = Node(None)

# Setting the correct previousext self._header.next = self._trailer self._trailer.prev = self._header self._size = 0

def print_list(self): """ Prints the current state of the list; Starting at the header and moving forwards. """ current = self._header.next list_str = "" while True: if current == self._trailer: break list_str += "{} ".format(current.get_element()) current = current.next

return list_str

def undo(self):

# TODO: Implement this:

# Undo the latest action.

return None

Starting with an empty list, the header sentinel and the trailer. trailer insert.first A headerA raler insert_before AB header remove A headertraler undo undo headerAtraler undo headertraler

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!