cpppro

Circular Linked Lists

In C Tidbits, Data Structures in C/C++ on May 17, 2007 at 5:54 pm

Please visit my earlier post linked lists for basics of linked lists. Visit this post for circular double linked lists

What is circular linked list?

Circular Linked lists are chain of records/nodes, one record/node points to the next, and last node/record pointing to the first node instead of pointing to a sentinel. Record/node holds the data.

Why circular linked lists?

Circular linked lists can be traversed from anywhere (given any node) in the list, which gives flexibility and it also enahnces efficiencies of some operations however it complicates operations by inducing special cases to deal with circularity of list

How circular linked lists look like?

Circular linked list

Operations On Circular Linked Lists:

 

Please refer http://www.refcode.net/2013/02/circular-linked-lists.html

 

Advertisements
  1. In the search algorithm,I think a small correction in the conditional check is necessary in the while loop to avoid running the loop forever on searching an element which is not present in the list.

    if (after == h)
    {
    //search element not found on the searching the entire list
    break;
    }

  2. yes, you are right..
    if(after == after->next) was placed mistakenly, which will be never true, until unless it is a single node circular list… good catch…

  3. Cool code, this helped me learn a lot.
    Thanks!

    -Echo
    http://www.echo.net84.net

  4. exellent code. it helps me a lot. thank u

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: