EXPERIMENT 5 – Circular Linked list
| 
   
1. 
 | 
  
   
Objectives:  
(a).      
  Understanding
  the concepts and operations of circular linked lists 
(b).      
  Implement
  circular linked list using dynamic structures. 
 | 
  
   | 
 |||||||||||||||||||||||||||||||||
| 
   
2. 
 | 
  
   
Time
  Required: 3
  hrs 
 | 
  
   | 
 |||||||||||||||||||||||||||||||||
| 
   
3. 
 | 
  
   
Software
  Required:  
(a).      
  Windows OS 
(b).      
  Microsoft
  Visual Studio 2012/ Borland/ Dev C++ 
 | 
  
   | 
 |||||||||||||||||||||||||||||||||
| 
   
4. 
 | 
  
   
Circular Linked List 
Circular Linked List is a variation of Linked
  list in which the first element points to the last element and the last
  element points to the first element. Both Singly Linked List and Doubly
  Linked List can be made into a circular linked list. 
 | 
  
   | 
 |||||||||||||||||||||||||||||||||
| 
   
5. 
 | 
  
   
Singly Linked List as Circular 
In singly linked list, the next pointer of the
  last node points to the first node. 
![]()  | 
  
   | 
 |||||||||||||||||||||||||||||||||
| 
   
6. 
 | 
  
   
Doubly Linked List as Circular 
In doubly linked list, the next pointer of the
  last node points to the first node and the previous pointer of the first node
  points to the last node making the circular in both directions. 
![]() 
As per the above illustration, following are
  the important points to be considered. 
·       
  The last link's next points to the first link of the list in
  both cases of singly as well as doubly linked list. 
·       
  The first link's previous points to the last of the list in case
  of doubly linked list. 
 | 
  
   | 
 |||||||||||||||||||||||||||||||||
| 
   
7. 
 | 
  
   
Basic Operations 
Following are the important operations
  supported by a circular list. 
·       
  insert − Inserts an
  element at the start of the list. 
·       
  delete − Deletes an
  element from the start of the list. 
·       
  display − Displays the list. 
 | 
  
   | 
 |||||||||||||||||||||||||||||||||
| 
   
8. 
 | 
  
   
Exercise: 
Make a circular linked
  list. Insert a number in integer part and in string its property as even or
  odd part of node structure.  
struct cnode{ 
int num; 
string evenORodd; 
.. 
…} 
Insert a new node at
  second last position and check for the node previously at the second last
  position if the number it is containing is even move to the start of the
  circular linked list and if it’s odd shift it to the last of the circular
  linked list. 
Even Case: 
 
 
                      move to  
 | 
  
   | 
 |||||||||||||||||||||||||||||||||





0 comments:
Post a Comment