LinkedList data structure. It is a linear data structure where elements are stored in a non-contiguous manner.
Each element is a separate object and contains a reference to the next and previous elements in the LinkedList.
Each element is called a node and consists of a value and a reference to the next and previous nodes.
The first node is called the head and the last node is called the tail.
TheLinkedListclasshasthefollowingmethods:
push(value: T): void - Adds a new value to the end of the LinkedList.
pop(): T | null - Removes the last value from the LinkedList.
shift(): T | null - Removes the first value from the LinkedList.
unshift(value: T): void - Adds a new value to the beginning of the LinkedList.
get(index: number): T | null - Returns the value at the given index.
set(index: number, value: T): boolean - Sets the value at the given index.
insert(index: number, value: T): boolean - Inserts a new value at the given index.
remove(index: number): T | null - Removes the value at the given index.
indexOf(value: T): number - Returns the index of the given value.
toString(): string - Returns a string representation of the LinkedList.
LinkedList data structure. It is a linear data structure where elements are stored in a non-contiguous manner. Each element is a separate object and contains a reference to the next and previous elements in the LinkedList. Each element is called a node and consists of a value and a reference to the next and previous nodes. The first node is called the head and the last node is called the tail.