Skip to main content

DoublyLinkedList.add_front

Adds an item to the front of the DoublyLinkedList

Usage

add_front(item:Any)

Parameters:
      item : element
            The new element will be added to the front of the Linked List.

Returns:
      DoublyLinkedList
            Returns the same Linked List containing the newly added item.

Example

from jellybeans.structures import DoublyLinkedListLL1 = DoublyLinkedList()LL1.add_front(4).add_front(3).add_front(2).add_front(1)print(LL1) # 1 => 2 => 3 => 4LL2 = DoublyLinkedList([5, 6, 7])LL2.add_front(109)print(LL2) # 109 => 5 => 6 => 7