Difference between Circular Linked list and Loop in linked list

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sathishc58
    New Member
    • Sep 2007
    • 34

    Difference between Circular Linked list and Loop in linked list

    Hi

    Can anyone explain me the difference between circular linked list and looped linked list?

    1) In Circular linked list Next part of last node will be pointing to the first nodes starting address.

    2) What is meant by loop then?

    Thanks & Regards
    Sathish Kumar
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    A circular linked list has the last element pointing to the first element. These are useful because you can use the prev pointer of the first element to access the last element immediately without having to traverse the entire list or by keeping an address somne where.

    Circular linked lists are often used where the number of nodes is constant. Like logs. Your can create a log that holds the last 100 entries by using a circular linked list.

    A loop in a linked list occurs when a node in the middle of the list points to another node in the middle of the list. Like A->B->C->D->B. When you traverse this list you get A->B->C->D->B->C->D->B->C etc... You can never get out of this loop. This is always an error.

    Comment

    • gpraghuram
      Recognized Expert Top Contributor
      • Mar 2007
      • 1275

      #3
      Originally posted by sathishc58
      Hi

      Can anyone explain me the difference between circular linked list and looped linked list?

      1) In Circular linked list Next part of last node will be pointing to the first nodes starting address.

      2) What is meant by loop then?

      Thanks & Regards
      Sathish Kumar
      Circular linked list is the one in which you have control and the loop in a linked list is one which is caused by memory corruption or coding mistake which u dont have a control on it

      Raghu

      Comment

      Working...