Implementation of link List In C
Learn the way of “Implementation of Link List in C and C++ program using DEV“. Link List is the linear NP Ds. here NP stands for non_primitive Ds.Link List is an abstract data type as Stack and Queue. It means that it is the imaginary data type.
- In link list it is we can take memory in Run time. Link list is used when the draw back of Array is occur.
- Link list is also use of Dynamically memory Allocation , and as well as the link cation between data because it is the linear Abstract Data type.
There are two types of link list:-
i) Simple link list ii)Circular link list
Simple link list:-
In Simple Link list the first Node is head Node and the one node is connect to next Node. Using this way the link list is said to be Linear Data Structure.
There are two types of Simple link list:-
i) Single link list ii)Double link list
i) In Single link list we use 1 link part.
ii) And In Double Link list we will use 2 link parts to link the data. It is also know as Doubbly Link list,
The Example of the Link list are as follows:-
Circular Link list:-
In Circular Link list the last node is connected to the first node. It will be created the link list just like as circle. For Example:-
The operations that will be perform using link list are as follow:-
i) Creation iii) Insertion v) Deletion
ii) Traversing iv) Searching vi) Sorting
In this post i will represent the program ” Creation and traversing of link list” using Structure and Class.
Here is the Implementation of Link list in C.
#include<iostream>
using namespace std;
struct Node
{ int data;
struct Node *next;
};
class Link_List
{
private:
struct Node *p,*q,*head,*t;
public:
int creat()
{ char y;
p=new Node;
cout<<“Enter value\t”;
cin>>p->data;
p->next=NULL;
head=p;
do
{ q=new Node;
cout<<“Enter value\t”;
cin>>q->data;
q->next=NULL;
p->next=q;
p=q;
cout<<“If you want creat more node then press ‘y’\t”;
cin>>y;
}while(y==’y’);
cout<<“End of Creation Link”<<endl;
}
int traversing()
{ t=head;
cout<<“Start the traversing”<<endl;
while(t!=NULL)
{ cout<<t->data<<endl;
t=t->next;
}
}
};
int main()
{
creat();
traversing();
}
did you like Implementation of Link list in C ??
The program of other four operation will be Add on next post. Insha_Allah
you may also like to read Solution of the Quadratic Equation by the program of C/C++ .Special Court Ordered to Arrest Pervez Musharraf Plea Reject.