Answers.Body: <p>One classic use is to implement a queue as a circular list. The reference to the queue itself is a &quot;pointer&quot; (or suchlike) to the tail, with the tail pointing to the head.</p>
  <p>It is then easy to add items (nodes) at the tail and remove them at the head.</p>
  <p>Another is to implement a set of tasks that must be performed in the same order repeatedly. A &quot;trigger&quot; is used as needed to advance the cycle and begin the next task. Some calendar tasks might be like that.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-25T10:13:36.670Z
Answers.LastActivityDate: 2023-03-29T11:12:28.303Z
Answers.LastEditDate: 2023-03-29T11:12:28.303Z
Answers.UserDisplayName: Buffy
Answers.Body: <p>Real world examples, used by people all the time, would be playing board games and card games where each player gets a turn, in order. Real world examples, used by computers all the time, could include multitasking for the CPU, where each process is given an opportunity to use the processor for some of it's work, each in turn. Real world examples for applications at the regular software developer's role could include a scheduling system for technicians on service work orders, to determine which person is assigned the next task, and after the last one in the list, the first one is next. Polling systems, where on central system regularly requests updated data, sales figures perhaps, from satellite offices, going from the first to the last and returning to the first.</p>
  <p>Based on this sampling I'm sure you can find examples your students would relate to either from their life in school, or projects they have in their coursework.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-22T17:19:24.590Z
Answers.LastActivityDate: 2023-03-22T17:19:24.590Z
Answers.UserDisplayName: Gypsy Spellweaver
Answers.Body: <p>As Gypsy Spellweaver proposed, I think that task schedulers are a good example, but I'd just like to put in another voice towards video games.</p>
  <p>A roller coaster track that the player builds is a good example, and so is a cyclic board in a game like Loop Hero.</p>
  <p>But we can also think about scenes in Unity.  You are on the main menu, which is a scene that is found... how?  It is a memory address.  You click &quot;Play&quot;, and it loads a new scene.  How does it find that?  Again, by memory address.  When you reach the end of your run, you are brought back to the main menu.</p>
  <p>Or perhaps you are first brought to an intermediary scene, with a score report.</p>
  <p>This is a natural cyclic linked list of size 2 (or 3).  The only wrinkle is that the nodes of the list are extremely complex, but a linked list it is nevertheless!  And the reasons for it are, I would hope, pretty intuitive.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-24T21:36:43.587Z
Answers.Text: I was, just the other day, wondering what the deal is with linked lists. Why would we use them now that we have invented trees, and hash trees. But reading this, I am now seeing them everywhere. They are just a special case of a directed graph.
Answers.UserDisplayName: ctrl-alt-delor
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-25T10:49:02.003Z
Answers.Text: @ctrl-alt-delor A _very_ directed graph at that. A single option for leaving each node and a single path to any node. Always moving forward. A tree with no branches.
Answers.UserDisplayName: Gypsy Spellweaver
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-25T11:11:18.883Z
Answers.Text: @ctrl-alt-delor "They are just a special case of a directed graph." Exactly. As are trees!
Answers.UserDisplayName: Ben I.
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-22T17:39:50.263Z
Answers.LastActivityDate: 2023-03-22T17:39:50.263Z
Answers.UserDisplayName: Ben I.
Body: <p>I told students that singly linked lists can have cycles. A student asked <em>why</em> one would. Are there good examples, or is it just something that comes up on job interviews?</p>
  
Tags: <data-structure>
Title: What is a motivating example for a cyclic linked list?
ThreadText: # What is a motivating example for a cyclic linked list?
  
  (Asked by: username_0 on 2023-03-22)
  
  I told students that singly linked lists can have cycles. A student asked *why* one would. Are there good examples, or is it just something that comes up on job interviews?
  
  **Tags:** data-structure
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_2 on 2023-03-22. Score: 2
  
  Real world examples, used by people all the time, would be playing board games and card games where each player gets a turn, in order. Real world examples, used by computers all the time, could include multitasking for the CPU, where each process is given an opportunity to use the processor for some of it's work, each in turn. Real world examples for applications at the regular software developer's role could include a scheduling system for technicians on service work orders, to determine which person is assigned the next task, and after the last one in the list, the first one is next. Polling systems, where on central system regularly requests updated data, sales figures perhaps, from satellite offices, going from the first to the last and returning to the first.
  
  Based on this sampling I'm sure you can find examples your students would relate to either from their life in school, or projects they have in their coursework.
  
  
  ---
  
  ### Answer by username_3 on 2023-03-22. Score: 2
  
  As username_2 proposed, I think that task schedulers are a good example, but I'd just like to put in another voice towards video games.
  
  A roller coaster track that the player builds is a good example, and so is a cyclic board in a game like Loop Hero.
  
  But we can also think about scenes in Unity. You are on the main menu, which is a scene that is found... how? It is a memory address. You click "Play", and it loads a new scene. How does it find that? Again, by memory address. When you reach the end of your run, you are brought back to the main menu.
  
  Or perhaps you are first brought to an intermediary scene, with a score report.
  
  This is a natural cyclic linked list of size 2 (or 3). The only wrinkle is that the nodes of the list are extremely complex, but a linked list it is nevertheless! And the reasons for it are, I would hope, pretty intuitive.
  
  > **Comments:**
  > **username_4**: I was, just the other day, wondering what the deal is with linked lists. Why would we use them now that we have invented trees, and hash trees. But reading this, I am now seeing them everywhere. They are just a special case of a directed graph.  
  > **username_2**: @username_4 A _very_ directed graph at that. A single option for leaving each node and a single path to any node. Always moving forward. A tree with no branches.  
  > **username_3**: @username_4 "They are just a special case of a directed graph." Exactly. As are trees!  
  
  ---
  
  ### Answer by username_1 on 2023-03-25. Score: 1
  
  One classic use is to implement a queue as a circular list. The reference to the queue itself is a "pointer" (or suchlike) to the tail, with the tail pointing to the head.
  
  It is then easy to add items (nodes) at the tail and remove them at the head.
  
  Another is to implement a set of tasks that must be performed in the same order repeatedly. A "trigger" is used as needed to advance the cycle and begin the next task. Some calendar tasks might be like that.
  
  
  ---
  
  