You are on page 1of 4

List gl)

node=
Data Link

Data1 Data2| Data3 Data4 Link

Date= int ,float, char, string,structure


n1 n2 n3

10 50 60

:advantages a

disadvantage: sguall

10 20

Singly-linked Lists-ylal Agaysi 1

Circularly-Linked Lists Äy ila lga 2


Doubly-Linked <li iUsai gå.3
Next Next Next

---|AIB]= Ic||D[
Prey Prev Prev
struct node int data; node * next;};

node *head-NULL,*n=NULL;

iyisi, NULL iglyla æ yiailil e ia head , n iall

n= new node; // 6 S I ä l l eLiil

cin>>n->data: //ill daa Jil

n->next=NULL;|/sali al ol giall ja ehc!


-1 NULL
n= 1000 if (head==NULL) head=n;

head=1000 and n=1000


vold
C#2t-Nade (n2deS haad , int
21
using name space std; 22

struct node int data; node ' next:: 22


24
4 void createNode (node int 2
5 void printNode (node 2¬
pne
data n:
NULL:
2
int main() 2 if (head=-NULLI
7 24 head-p:
else
node head-NULL, 'n-NULL:
31
lnt %; 32 P-rext-head:

10 for (int i-0;i<5;it1) 33 headp:


34
11 35
12 cout"Enter the num: 3¬
37 void pintNde inode headi
13 Cin X;
3
14 CreateNode (head, x); 39 node p head:
40 cout c"\n The Informa tior: node:
1 while (p!ULL
41
16 42
17 printNode (head) : 43 cout p-data
44 Ppnext:
18 4
19 return ; 4¬
47
20

#ludestrear
using naNespace std; 3

struct studEnt int 1d;string nae:string depnané:int age: : !


struct node sTUdent sl; nodt next::
void createNode (nodE i Student :
void puintNode (node :
int màln

head-NULL, 'n-NULL:
student sl:

12 for (int i . i i
13
14 cout "ENLeI the id:="
15 Cin$1.10:
toutr Enter the ranE;= 4

cins1.dephane:
26 43
cin>51. Agt
tteatfNcd: head sl:

24

2
returo ;
n=1001 40 NULL if (head==NULL) head=tail=n;else {tail->next=n;tail=n;}
head-1000

1000 1001 1002


-1 1001 40 1002 50 NULL

head-1000 and tail-1002

node * p=head;

cout<<p->data;

pp->next;

i l e 50 Ãclub piay data=50 iiy p=1002 åa Ükiu

You might also like