LinkedList constructor
initial data as array
LinkedList iterator for iteration across all nodes
LinkedList iterator for backward iteration across all nodes
Clear all values in LinkedList
Complexity: O(1)
Find first node by value in LinkedList, used comparator function, linear search
Complexity: O(n)
Find last node by value in LinkedList, used comparator function, linear search
Complexity: O(n)
Determines whether a value is in the LinkedList
Complexity: O(n)
Insert value or node after node
Complexity: O(1)
Insert value or node before node
Complexity: O(1)
Insert value or node first
Complexity: O(1)
Insert value or node last
Complexity: O(1)
Remove node by reference or value from LinkedList
Complexity:
Remove first node from LinkedList
Complexity: O(1)
Remove last node from LinkedList
Complexity: O(1)
Reverse order of list nodes
Complexity: O(n)
Export LinkedList to array
Complexity: O(n)
Linked list
In computer science, a linked list is a linear collection of data elements, whose order is not given by their physical placement in memory. Instead, each element points to the next. It is a data structure consisting of a collection of nodes which together represent a sequence. In its most basic form, each node contains: data, and a reference (in other words, a link) to the next node in the sequence. This structure allows for efficient insertion or removal of elements from any position in the sequence during iteration.
source: www.thecodingdelight.com
Complexity
O(n)
O(n)
O(n)
O(n)
O(1)
O(1)
O(1)
O(1)
O(n)
O(n)
Reference
import { LinkedList } from '@pencroff/ts-algorithms/dist/structure/linked'; const list = new LinkedList([1, 2, 3])
LinkedList implements
generic
doubly linked list