English First node (the head) of a circular linked list

1 reply
Goto Page
To the start Previous 1 Next To the start
Up
hilton82
User
Offline Off
I have a query about a circular linked list.

1. How do you find the first node (the head) in a circular linked list?

2. What is the practical application of a circular linked list, and why do we require it?

I searched numerous forums and websites but was unable to find appropriate answers.

Thank you for taking the time to read this.
22.06.22 02:14:23 pm
Up
ohaz
User
Offline Off
1. A circular linked list has no inherent head. It's a circle. You can have lots of heads. It's probably just an external structure linking to one of the elements.
You _could_ have one "special" element (e.g. one without a value, just the links) which you could use as a head, then you could search for that one. But that's not usually done.
2. You can use it for everything where you want to keep a specific amount of entries, a new one kicks out an old one. E.g. if you want to keep the last 20 temperature values on your thermometer, you can use a circular linked list for that. Just always do head = current->next; head.temperature = current_temperature.
https://ohaz.engineer - Software Engineering
To the start Previous 1 Next To the start