-
Book Overview & Buying
-
Table Of Contents
Learning JavaScript Data Structures and Algorithms - Fourth Edition
By :
A circular linked list is a variation of a linked list where the last node's next pointer (or tail.next) references the first node (head) instead of being null or undefined. This creates a closed loop structure., as we can see in the following diagram:

A doubly circular linked list has tail.next pointing to the head element, and head.previous pointing to the tail element as showed as follows:

The key difference between circular and regular (linear) linked lists is that there is no explicit end to a circular linked list. You can continuously traverse the list starting from any node and eventually return to the starting point.
We will implement a singly circular linked list, and you can find the bonus source code for a doubly circular linked list in the source code from this book.
Let's check the code to create the CircularLinkedList class:
class CircularLinkedList...Change the font size
Change margin width
Change background colour