Skip to main content

TailedLinkedList.update

Update the value of an item at a specified index

Usage

update(index: int, new_item:Any)

Parameters:
      index : int
            The index of the item to be updated.
      new_item : element
            The new item to be inserted into the TailedLinkedList.

Returns:
      TailedLinkedList
            Returns the same Linked List with the updated item.

Example

from jellybeans.structures import TailedLinkedListLL1 = TailedLinkedList([10, 3, 7, 29])LL1.update(1, 11).update(2, 12)print(LL1) # 10 => 11 => 12 => 29LL2 = TailedLinkedList([5, 6, 7])LL2.update(1, 15)print(LL2) # 5 => 15 => 7