(self, data)
Note: The average time for append is O(n)
            however, insertion is O(1), giving it an
            advantage over arrays.
Note: The average time for append is O(n)
            however, insertion is O(1), giving it an
            advantage over arrays.
Note : The average time for append is O ( n ) however insertion is O ( 1 ) giving it an advantage over arrays .
def append(self, data):
        """ Note: The average time for append is O(n)
            however, insertion is O(1), giving it an
            advantage over arrays.
        """
        if self.head is None:
            self.head = DoublyLinkedNode(data)
            self.cursor = self.head
        else:
            node = self.head
            # This is a common pattern with linked lists
            while node.next is not None:
                node = node.next
            # A simple change to use the double node
            # and link the previous
            new_node = DoublyLinkedNode(data)
            node.next = new_node
            new_node.prev = node
        self.size += 1
def append ( self , data ) : if self . head is None : self . head = DoublyLinkedNode ( data ) self . cursor = self . head else : node = self . head # This is a common pattern with linked lists while node . next is not None : node = node . next # A simple change to use the double node # and link the previous new_node = DoublyLinkedNode ( data ) node . next = new_node new_node . prev = node self . size += 1