© 2012 Firstsoft Technologies (P) Limited. login
Hi 'Guest'
Home SiteMap Contact Us Disclaimer
enggedu
Quick Links
Easy Studies
« NS2  Projects »

Home Lab Exercise Data Structures Lab Exercise Programs Implementation Of Circular Linked list▼



Implementation Of Circular Linked List:

Circular Linked List:

           In circular linked list the pointer of the last node points to the first node.

           It can be implemented as singly linked list and doubly linked list.

Advantages of Circular Linked List:
         
          1. It allows traversing the list starting at any point.

          2. It allows quick access to the first and last records.

          3. Circularly doubly linked list allows traversing the list in either direction.

Algorithm Steps:
 
          Step 1: Create the pointers prev, cur ,last.

          Step 2: Read the operation type of the list.

          Step 3:  If the operation type is Insertion then

                     i) If insertion at beginning is true

        1. Create the new node and allocate memory for that node.
        2. Read the data in new nodes data part.
        3. Assign cur->link = last->link (now cur->points first node)
        4. Assign first=cur (move the first to cur)
        5. Assign last->link =first (now last -> link points new first node)

                     ii)  If insertion at between any two nodes is true

        1. Move the prev pointer to required position
        2. Create the new node and allocate memory for that node.
        3. Read the data in new nodes data part.
        4. Assign cur->link = prev-link (give the link to next node)
        5. Assign prev->link =cur.

                    iii)  If insertion at end is true

        1. Move the prev is to last position ( ).
        2. Create the new node and allocate memory for that node.
        3. Read the data in new nodes data part.
        4. Assign cur->link =prev->link
        5. Assing prev=cur.

                     Step 4: If the operation type is deletion then

                                  i) If deletion at beginning is true then

        1. Assign first=last->link->link (Move the first to second position)
        2. Assign cur=last->link
        3. Assign last->link=first
        4. Reallocate the cur from memory.

                               ii) If deletion between any two nodes is true

          1. Move the cur to required position.
          2. Move the prev to cur predecessor’s position.
          3. Assign prev->link=cur->link
          4. Reallocate cur from memory.

        iii). If deletion at ends is true

            1. Move the cur to last position.
            2. Move the prev to cur’s predecessor position
            3. Assign prev->link=cur->link
            4. Reallocate cur from memory

                   Step 5: If operation type is traverses

        1. Assign cur=first
        2. Repeat the process untill cur becomes last Cur=cur->link
C Program To Implement Circular linked list

CPP Program To Implement Circular linked list
 
SLogix Student Projects

⇓ Student Projects ⇓
⇑ Student Projects ⇑
bottom