Move element pointed by position p to back

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. 
  """

Problem information

Author: Josefina Sierra Santibáñez

Generation: 2026-01-25T19:59:03.941Z

© Jutge.org, 2006–2026.
https://jutge.org