/*********************************************************
-> This C++ program is to perform the following operations
on a circular linked list
1)insertion
2)forward traversal
3)reverse traversal
4)search
->node structure :
a node contains
1) integer data
2) pointer to next node
-> This program works in microsoft VC++ environment
in windows xp
-> This program uses the following header files
1)iostream.h
********************************************************/
#include<iostream.h>
class cll
{
private:
int data;
cll *next;
public:
cll* insert_one(int,cll*);
cll* delete_one(int,cll*);
void ftraverse(cll*);
void rtraverse(cll*);
void search(int,cll*);
void function();
};
cll*hd;
void cll::function()
{
cout<<”******************************************\n”;
cout<<”program to implement a circular linked list \n”;
cout<<”******************************************\n”;
cll * head;
head=NULL;
cout<<”\n\nMENU :\n”;
cout<<”1)insertion\n”
<<”2forward traversal\n”
<<”3)reverse traversal\n”
<<”4)search\n”
<<”5)exit\n\n”;
cout<<”Enter your option :”;
int opt;
cin>>opt;
int d;
while(opt!=5)
{
switch(opt)
{
case 1:
cout<<”Enter data to the node :”;
cin>>d;
head=insert_one(d,head);
cout<<”inserted\n”;
break;
case 2:
cout<<”The forward traversal is :\n”;
ftraverse(head);
break;
case 3:
cout<<”The reverse traversal is :\n”;
hd=head;
rtraverse(head);
cout<<”NULL\n”;
break;
case 4:
cout<<”Enter the element to be searched :”;
int d;
cin>>d;
search(d,head);
break;
case 5:
break;
default:
cout<<”invalid option”;
break;
}
cout<<”\n\nMENU :\n”;
cout<<”1)insertion\n”
<<”2)forward traversal\n”
<<”3)reverse traversal\n”
<<”4)search\n”
<<”5)exit\n\n”;
cout<<”Enter your option :”;
cin>>opt;
}
}
cll* cll::insert_one(int d,cll* c)
{
cll*NEW;
NEW=new cll;
NEW->data=d;
NEW->next=NULL;
if(c==NULL)
{
c=NEW;
c->next=c;
}
else
{
cll*c1=c;
while(c1->next!=c)
c1=c1->next;
c1->next=NEW;
NEW->next=c;
}
return c;
}
void cll::ftraverse(cll* c)
{
if(c==NULL)
{
cout<<”\nlist empty\n”;
return;
}
else
{
cll *c1=c;
cout<<c1->data<<”->”;
c1=c1->next;
while(c1!=c)
{
cout<<c1->data<<”->”;
c1=c1->next;
}
cout<<”NULL\n”;
}
}
void cll::rtraverse(cll* c)
{
if(c->next==hd)
{
cout<<c->data<<”->”;
return;
}
else
rtraverse(c->next);
cout<<c->data<<”->”;
}
void cll::search(int d,cll* c)
{
cll*c1=c;
if(c==NULL)
{
cout<<”\nlist empty\n”;
return;
}
else
{
if(c->data == d)
{
cout<<”found\n”;
return ;
}
while(c->next !=c1)
{
if(c->data==d)
{
cout<<”found\n”;
return ;
}
c=c->next;
}
if(c->data ==d)
{
cout<<”found\n”;
return ;
}
cout<<” search unsuccess ful \n”;
}
}
void main()
{
cll list;
list.function();
}
please i need the ansewer of a c++ progra using circular linked list . the quation is to remove , find,print,findkth,insert,input.keep in touch,
it will be so kind of u if u will mention theory parts of data structure and c and c++
hi… have a nice day…….
ahm’ can I ask for your help?
plz help me in my final project in data structure…..
it’s required an application.
Hello
I just want a program in C that accepts two circular Linked Lists in C ,Displays them,Sorts them and merges them
hello ,can you help me.
i want proper algo. to reverse a circular linked list .
pleaser eply early b’coz i have my exam on saturday.
could u please give the algorithm to traverse the circularly linked list and doubly linked list
asdasdasdasd
plz reply coz i hav got exams after 2 days
i want the delete function in link lisyt in such a way that we can delete the alternative linklists
PLZ i need al topics of DATA STUCTURE(DS) .
help me!!!!!!!……
I need all topic of DS .
help me out plz!!!!!!!!!……
heloo sir/madam….
i need all the topics of DS.plz provide the content with the figures to understand vry easily …
i dnt knw anythng abt DS …
iam interested to learn from the basics of this.. plz help me…
thank you
………
i need simple algorithm of circular linked list
pgm for circular linked in c
pgm for circular linked list in c
i need a theory part to explain theory part here
i need algorithm for circular link list
wap c program to create linked list with given number in which data part each node contain saparate digits of the number
sir plgs tell me program wap c program to create linked list with given number in which data part each node contain saparate digits of the number thank you
i want this program output