You are on page 1of 5

Assignment No 3 Date

2 3

Linked List
1Explain made atructure _of Sll,DLL. SCL,Dcl._
Node siruciure of dingly linked list:

Stuct node O ypedel Shruct node


int intoi int into:
Gluck node *nexti Struct node * next
NODE
Node atruchure of Doubly linked list:
Struct node Or_upedet StruCt node
int intoi int info;
Struck node prev, t next: Struct node *prev,*nex
NODE
Nnde Struckre oB Singly Circlar linked list
NOde
info ne

node Ode
ode Ylode

Node Sruckire oB Doubl Circular linked list:

Dala K
C Yev
Dat

.lhatis Linked List2 List the_difterent


of linke.d list2_ ype
A inked lis is an _mdered collection of data elements
ohich are Stpred_at gandom memoT locationa
S linkedL one
anothe..
1here ae ouY ypes of inked lists:
Singly Linked Liat
2. DoublyLinked List
3.Singly Circular Linked ist
4. Doubly Circulax Linked 1LiSt.

8.ulhat is genexalized linked list? £xplain in_detail.


A qenexalized limKed list is a Special kype of linked
1st,_ohich natonly contains indivi dutal data itema
but also containS pointers toatber lishs. -.

has Gublists..
A generalized list G is inite Gequence ot nz20
a

elementS a an ohere i ae either akoms__ox


ksts These lists a i e called tre Sublists of G

4LJhat is cinclar linked list


A circular linhed list is a linked listin_ohich the
last mode points to he first node f tthe list

5Writea "c" £unction t o insett& delele _an element


cd particular pasiHon in SLL._
Inser at Specilic poSition:
Void insert NoDE *head,int Mum, int pos)

NODE*neonode temp;
int is
*oye temp to node at pos
-1
¢4lii=pos-0: i+
torCtemp=head.i=li (Hempl=NUL
temp=temp>next:

iHCtemp==NULL2
of range")i
PaintfC "Pasilion_ i6 out
e un;-

Mewnode=CNODE*malloc CSizeofCNoDEM
newncdeinBo= Dum;_
temp->nexBZ
Insest neonade hetween temp §
newnode-> next = temp>nexti
tenp next newnndes

Delete aB Specilic position:


Void deletepas CNoDE *head, int _pos)

NoDEtemp, *empli
int is
*love temp tu node at pas - 7
o r Ctemp=head, i=ls (temp-ncxtl=NULLY & S
Cis=poS-D: i+t
temp=iemp-nexti
ifCtemp- 2next == NULL

printf Hhsilion is aut oi


Tange");
Keklrn;

temp1= Lemp2nexts
tempnext= templ nexti
ree Ctempl);
Data

Claite a c uncion to_display even element


Cdata) in aSingle linked list-_of inleger
oid displayEven CNODE *head)

NODE temp;
forCtemp=headnext; termpl=NVLi temp=temp-2nex)d
ifCtempintoz2==0)
pinttC"Zd\t"> temp->into)i

7.Write a "C"tunction to pertom addikion of


elementsa evenposition io doubly linked list of
integers
i n t SumevenC NoDE *head, int n

NODE *temp;
int pos, Sum=0
for(temp=head,pos=Os temp=NDL; temp=kemp->nexl,
pastt)

iflpoS2 ==0)

Sum=tempdata +Sum;

printiC\n the Sum of_even node is d Sum)3

-3.ile a difference betneen_ Artay& linked List.

Array lioKed List


An aYray 1S a Static List is_a dynamic data
dada stuuctue ie. the Gtrucke. The Size of h
TEman ixe
Size af the array remaing list may not
Hxcd Las elements aIe inseste
k deleked

Alla.os only Sequential


AllaasIandom_access n-
access.
elements.
List _operatons are slooe.
ii Aray operalians are taster
implementaion List implementalion
liv Array i s complex.
i s easiex.

9.Wha is the advantaqeS of linked list


Since memar i s dynamicaly allocated duzing
ulilized.
un-ime, memry is etHciently
2. There is m o limit o n the numher of nodes:
excepttor the ayailable memory
3. Tnselion, deletion & traversal can_be eilily
done
4 Memoy Can be treed
ehennodes_haNe to be
deleted.

You might also like