By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,630 Members | 1,121 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,630 IT Pros & Developers. It's quick & easy.

Difference between Circular Linked list and Loop in linked list

P: 34
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
May 21 '08 #1
Share this Question
Share on Google+
2 Replies


weaknessforcats
Expert Mod 5K+
P: 9,197
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.
May 21 '08 #2

gpraghuram
Expert 100+
P: 1,275
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
May 22 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.