Every linked list is a chain of nodes joined by pointers. What changes between the three types is which pointers each node has and where the last node points. That one choice decides which directions you can walk, what each operation costs and what the list is good for.
Each node holds a value and one pointer, next. You start at the head and can only move forward; the last node's next is null. It is the simplest and lightest type, and the one most interview questions use — every lesson so far has been about it.
next), so deleting a node you're pointing at means searching from the head: O(n).Each node holds a value and two pointers: next to the node after it and prev to the node before it. The head's prev and the tail's next are null. Because every node knows both neighbours, you can walk in both directions, and you can unlink a node you're holding in O(1) — no search for its predecessor.
class Node { constructor(val, prev = null, next = null) { this.val = val; this.prev = prev; // the node before, or null at the head this.next = next; // the node after, or null at the tail }}The price is one more pointer per node (8 bytes on a 64-bit machine) and twice the pointer updates on every insert and delete — forget one and the two directions disagree. Real libraries use doubly linked lists: Java's LinkedList, C++'s std::list and Python's collections.deque (blocks linked both ways).
The last node's next points back to the first node instead of to null. There is no end: from any node you can reach every other node, and a walk that doesn't stop on purpose goes round forever. A circular list is usually held by its tail rather than its head — tail.next is the head, so both ends are one step away and adding at either end is O(1).
function buildCircular(values) { if (values.length === 0) return null; const head = new ListNode(values[0]); let tail = head; for (let i = 1; i < values.length; i++) { tail.next = new ListNode(values[i]); tail = tail.next; } tail.next = head; // close the ring: the tail points back to the head return head;}A circular list can also be doubly linked: the head's prev points to the tail and the tail's next to the head. Operating systems schedule processes round-robin on such rings, and music players use one for repeat all.
next only, forward only, ends at null. The lightest and the most common.prev and next, walks both ways, unlinks a held node in O(1) — at the cost of one more pointer per node and more pointers to update.