All lessons

3. Linked Lists

Circular linked lists

0 of 5 activities0%

Reading 1

No nullptr at the end

Open

In a circular singly linked list, the last node’s next points to head. Traversal must stop after returning to the start, not at nullptr.

Useful for round-robin scheduling and ring buffers.

Be careful with empty and one-node circles.

// stop condition sketch
Node* p = head;
do {
  // use p
  p = p->next;
} while (p != head);

Check 2

End test

Open

In a non-empty circular list, traversal usually stops when

Fill in 3

Shape

Open

A list where the last node links to the first is called

Try it 4

One-node circle

Open

Self loop.

main.cpp
Loading editor…
Output will appear here.

Assignment 5

Print yes if circular concept

Open

Read n. If n>0 print circular, else print empty.

main.cpp
Loading editor…