0% found this document useful (0 votes)
2 views17 pages

Linked List

The document discusses various aspects of linked lists, including their structure, operations for insertion and deletion, and the differences between singly and doubly linked lists. It also covers how to dynamically create linked lists and handle memory management. Additionally, it highlights the advantages of circular linked lists and the efficiency of operations performed on them.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views17 pages

Linked List

The document discusses various aspects of linked lists, including their structure, operations for insertion and deletion, and the differences between singly and doubly linked lists. It also covers how to dynamically create linked lists and handle memory management. Additionally, it highlights the advantages of circular linked lists and the efficiency of operations performed on them.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

nked ist ) Tseti oterenhat Data Rhuctue

k e y l a a t n :

nenvde

]000 o00

studt node
int data; declarahion
stuct n ode * next* dt doent
allo ate any
3;
Coeatag tct node)
ghuct node a

’ urdat'ng addreses to fom the dtsta)


Q n e t anext b

("nextkd.

<tuet nodhe s Coanthg ponter]


’ As s is a pahteY Va ot a node pointed
by sS Cen be acce dsed ag (S). data
S datg
(9)

Aocahin.
-) Tn lhked ict, hefoce doy ang sporati away
check

and comuting 8-s nert then

at wl gentrat ero. [kefmentahm)


Almple cxarmple to gnerate hked :+
Howeer to do it dynameallybe follan'ny procedue

stut node s= N ;
( aeirerent
:) erey thme st we wj4 creatt a hede ay per

nmdea) nallec (s'heot (atuct node))


P-(nct

Costag
. He nserton tunchm Hat talees stott pontr S ay an
ahput

rehn(s);
eif (s ’ext Nul )
Rsnest= P; vehm(s);
he
e inked :
dat nde of
-) Ahdiis he adlveu ¡f

s)
Shut node *f l a t (shuet node

Cntl e ("-enpty";
vehnl)
ele

ls=s’net;
3
rehnC);

3ize la)

Vectorelat)
cs ize

atnde)
’ for seCmd
too posntrs Single pahter

S -Ssney*; rehnn ().


rehnn l)
(L

) fhding addreu of a node wih tontas daty'! in

)
<tut node * fnd.r(aluct node. ts, dnt

f("Lked ti'st empt";


rehn (nwl);
ie

element
ifls daay x)
rehn Cs).
bet
eue
vehnlnwla);

Iaterhon-) () At He

40

ol)
()

tronn st node
f t netd to tawerit alankng
to dast Hen
node

So hile ( S,neyt) zNul )

foretoy af hy
ii) before no de haing v e 3o (o be any pas.

4o

ihels day! o ck Sinest!=

S,S,et;

3elsevehan(s);
netunl
A-Co de fomat ) (13)
shuet (rtate .hode(
int x)
hode (reahng 4 hode hoadag
data Vale ay

(ohact maloc (4ireof (ahuct node)):


P nOde*)

Null

retn (P);

hode * hsextast stuct node *s, intE


stuct
if{s== Nul)
rehn (nu) 1 enphy
LL.

stuctno de tp (reatenode (x):

stut node *f

Pnert S;

yehnn (s);

3
) DelehÝn:)
(t) Aat node Aelahie
node hehsee n.
(Iii ) Ang

4oo0

()

Snet

nerefit pontnj.
to loeahon Icoo h h h
Herefor)
knan ay danghg
Hatst pa'nttr

) 20

KotdeS, ’ntat |ENwu).


çi) delekngy an hehween a node hamag vale .
data

(S data = =*)
= S,’nest
P nex t

free (sm);

e:

3
(16
mang last node of a iaked ist to He beging

harelastnode shuct node ys )

Pf(uis emphy); hin (nul),;

rehunn (s);

S ett S

yehan (s;
3
inke U'st

Midnode(&huct node ts )

() lL enphy chee.
( ) I-element L heck.

(ii1) shilel sinext| Nul)

2
hile (3< f1)
on) S=S’net

etnls)

net|
wal )
P=pner
1-1next nert

}retnn()
3
:) Renerg a hked di'st )

enerse (s)

P11
Yetnet

9’ next ;
Aineed ist by wsg
3 Aes an 3 pgnts

vehhnls)
Dravbade ot iagle inted ist )

B000 4000

go Back as eveny fau'ns asigle


nde con taing
(i We Canit
hat greslpaats to next node.
pohkr
dast node that next part
dhiced dist
( ) Ta Siogle null hat heans be ae
We alsays stomig
net utiing it prpeey
eliate abe two eswbacky
we ae

toy Cisculan ihed 'st.


Malce

akeddit)
’ Ciculah single

looo

We an go badk
na He tmne Conple xiy
L i dbe on)
(P>nex t l=s)
Tnsehon n a Cirular dinkedist )

at dat
() heach to a node ohere SI ’ hext==s

(i) P next= Sinext

o()
at begining
()
gbeneht ing isk naw. tranYe SL to last nhe
Grla) nked
atlest
4f Set pon er inserhen Hhen (s1-nest)-s)
node then oli) Sl ’ next P:
Psssble fo be th
frontand layt
Deletin
at latt tal )
() Jeach ho last and becond dast node
SL S

free (s1); oln)


at fsnt-) () se ach to last de
S1 ’next s ’ nex t
free lo). pzokul
o)
end)
Tnseshe al He

) net p
ey hon at he front Pnet 2 E - n e x t ; cl)

Enex P

:) Doble<puthy dinked dist )


sbuct node sbuct nde t*pre
int data
8huct node 4 next:

20o
too0
newnde oreatenote(x)

Tnsertin ot he end ) P-’ pree Nul;


(W L-emphy cheek.
sehan(; pdata > ;

hle SL hest J=N )


Snxt
sl Pprer rehhnls);
Snert P: pprev S
Tases bion n behoeen:) (m belore anode

(30)

CAemen
L

S2=sJ;

= 3o )
St ’ data

Prer = 2 ;

P
S1’ rer =

else

3
Ielenent
f (s deta
nat }

rehmnls),;
nede at he end:)
Deleky a

SI nextl Nul)
hile(

th behveen)
belehing.
'SHnext!
Nl)
data! 30 ek
tle

-3o)

o(n)
free (sd;

else fond);
(
Civadan Srnbly dinted i))

mosty onerahon con be perfomd


- Jn civulan Dll,
Hn o() time

's thet if we lottany nk


’ Atentage of cL

tage ih bete CDLL and DLL


1 greahst a dran
s Hat you los t one
we Can get back.
ot another ponter

You might also like