Skip to main content

LinkedList.add_front

Adds an item to the front of the linkedList

Usage

add_front(item:Any)

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

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

Example

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