In the public_files section of the problem statement, a class called PositionalList, which implements the Positional List ADT using a doubly-linked list, is defined. Extend the implementation of this class with a new public method move_to_back(self, p). This method moves the element pointed by p to the back of the list instance calling it.
For example, if t is an instance of the class PositionalList that represents the following list and p is a valid position pointing to the first element of t (i.e. p points to 1),
1, 2, 3, 4, 5, 6
after executing the statement t.move_to_back(p), the object t will represent the list
2, 3, 4, 5, 6, 1
In particular, you should add the following public method to the PositionalList class:
def move_to_back(self, p): """ Moves element pointed by p to the back of the list. Pre: p is a valid position for the list calling this method. The list is not empty. Post: The element pointed by p is moved to the back of the list. The rest of the list has not been modified. """
Input
6 1 2 3 4 5 6 0
Output
list t: 1, 2, 3, 4, 5, 6 6, 5, 4, 3, 2, 1 list after moving 0-th element to back, t: 2, 3, 4, 5, 6, 1 1, 6, 5, 4, 3, 2