JS - Linear Data Structures 01
Linear Data Structures
Linked List
- The list is comprised of a series of nodes as shown in the diagram.
- Is a sequential chain of nodes
- The head node is the node at the beginning of the list.
- Each node contains data and a link (or pointer) to the next node in the list.
- The list is terminated when a node's link is null. This is called the tail node.
- Can be unidirectional or bidirectional
- The LinkedList class only kept track of the head of the list.
Test the LinkedList:
You should see this in the terminal
Doubly Linked Lists
- Are comprised of nodes that contain links to the next and previous nodes
- Are bidirectional, meaning it can be traversed in both directions
- Have a pointer to a single head node, which serves as the first node in the list
- Have a pointer to a single tail node, which serves as the last node in the list
- Require the pointers at the head of the list to be updated after addition to or removal of the head
- Require the pointers at the tail of the list to be updated after addition to or removed of the tail
- Require the pointers of the surrounding nodes to be updated after removal from the middle of the list
Test the DoublyLinkedList with
Queues
Stacks
Hash Maps