Doubly Linked Lists

https://cs.slides.com/colt_steele/doubly-linked-lists

We Know what lists are… but doubly?

Almost identical to singly Linked Lists, except every node has another pointer, to the previous node!

image.png

Comparisons with Singly Linked Lists

More memory === More Flexibility

      it’s almost always a tradeoff!

Singly is one directional whereas doubly is 2 directional prev and next.

Setting up our Node class

//Node
//-val
//-next
//-prev
class Node{
	constructor(val){
		this.val = val;
		this.next = null;
		this.prev = null;
	}
}

//Doubly LinkedList
//-head
//-tail
//-length
class DoublyLinkedList{
	constructor(){
		this.head = null;
		this.tail = null;
		this.length = 0
	}
}

Pushing

Adding a node to the end of the Doubly Linked List

Pushing pseudocode