Class LinkedList

Represents a linked list.

Hierarchy

  • LinkedList

Constructors

Properties

head: undefined | LinkedListNode

The head node of the linked list.

tail: undefined | LinkedListNode

The tail node of the linked list.

Methods

  • Clears the linked list by setting the head node to undefined. TimeComplexity = O(1)

    Returns void

  • Returns the data of the first node in the linked list. TimeComplexity = O(1)

    Returns unknown

    The data of the first node.

  • Initializes the linked list with nodes created from the elements of the specified array. TimeComplexity = O(n)

    Parameters

    • data: unknown[]

      An array containing the data for the nodes.

    Returns void

  • Returns the data of the last node in the linked list. TimeComplexity = O(1)

    Returns unknown

    The data of the last node.

  • Removes and returns the data of the last node in the linked list. TimeComplexity = O(n)

    Returns unknown

    The data of the last node.

  • Inserts a new node with the specified data at the end of the linked list. TimeComplexity = O(1)

    Parameters

    • data: unknown

      The data for the new node.

    Returns void

  • Removes and returns the data of the first node in the linked list. TimeComplexity = O(1)

    Returns unknown

    The data of the first node.

  • Converts the linked list to an array. TimeComplexity = O(n)

    Returns unknown[]

    An array containing the data of all the nodes.

  • Inserts a new node with the specified data at the beginning of the linked list. TimeComplexity = O(1)

    Parameters

    • data: unknown

      The data for the new node.

    Returns void

Generated using TypeDoc