What is a Circular Linked List?
Both non-empty singly linked list and doubly linked list have a terminating point which is defined by a node pointing to the null (head.prev == nil
or tail.next == nil
).
In circular linked list, however, there’s no node where it points to the null. If implemented with a singly linked list, the last node, tail
, will point back to head
. If doubly linked list was used as a base of a circular linked list, head.prev
will point to the tail
and tail.next
will point to the head
creating a circular, endless list.