0% found this document useful (0 votes)
20 views25 pages

DS Assignment - 04

Uploaded by

Ayush Gunge
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)
20 views25 pages

DS Assignment - 04

Uploaded by

Ayush Gunge
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/ 25

/Page No.

shrikent 723
Date Fage No. -Shrikant
4723 Date 1

Assianment No4 lcLst nert nednade


Linked lis Ao de
Lag n

SET A lis wh
o implement a Sng
ren
alAP Dis p layC)
ond Disoley 0pemrodim- Yoid
truc nade emp
inclule stdio h pnt nNade ore n "),
inc lude Stdlib.h

Suct ade
mp ne)
o t dcete
n eNT
pcintf 3d emp deda)
STu node
Sruct_= NULL

Void modo C)

NOd dreale c)
uct nde l0SF newnode Noid Disploy
inE Cl EA lenn clSo C
Can C n tot (etuc no de x) mallac Csize o f
Stc nadeD
fexr Ct04n44 Stonc neete NULL

newnode Cstru nade malloc szed stunl Cre oe


hade) Disob
newnado> neR t NUL
pocintE nEnier dado
Stont C newnode dadta
Pge NO, shrikanty
Cate:

723 Shrikant
723 Page No.
Date

linked lig

AP o
l e n m e n l _ C S i n a

C) int i
Cyeode
ro de * ne node
Eo lloain pexalino
display C
node emp
Ioseyt)
fox E0 n jit)
dele te
newnade getnade C
include stdio h i Cstor NULL)
tincude stali b-h)
8tor Deuno de
mple roentodian_a c
duct_alink.edlist
else

in dodei
Stractslin ked
list*next mo 3to
while Cemo nezt = NULL)
pe def Strucf &lin Kedlist no d-e emp emp nest
emp eKÅ =newnede_
node tor NULL
eoke ade Cy SLL
nade * getnode C)
no de newngde Yod Displts Displa L
newno de Cno de ) modloc S i2eo n o d e ))
OintE Cn Entes odo ) nade mn
Scon FC d newnode d ota _ prlndf n &ag inkedlis
newno de n eN NULL Ses emn8i Cd emo NU LLemp
returh nenode

Yoid Creode Cintn) e ke SL h rindf( 8 mp daua


Noder
Page No. -shrikant
723 Shrikant
Date:

L723 Page No.


Date: 1

Caud
cth)Coundina Naze 1ECStorf== NULL)
ntCountnode Cnade

int count0 start neuwn0de


Luhile p t r NULL)
else

couAt
ptr next emp Stom)
while Hemp Dext NULL)
etuan & Co und demp emp next
Lemp next E neuno de
Nacle A he cainn
Vod Ins-be c)IIne
nade new ngcle Noid Ins-pos nseri Nnde Lnkimedioht
newno de=etnade Positinn
Csto NUL
node newnade_ * ke mp rey
Stonc E NeLwna d in pOS nadecir cY&
newnode e t nade
else Dsinde Cn Endey Pos Aion
3 Conf C d Pas
neun0c n e n t _t c t nadecty Coundnade Cgtor
swnode ECPos7 L os 2nedecty )

emp s stoo = p7ey


Ynid nsenend C)Ise ole Adhe Drd while Cctn pos)

nod-e newn0de emp em p eN


Metindde get node dempdemo -e
Pege No. Shrikant
Date
Shrikant
723 723 Paga No.
Date

rey next =neaynode


F Cstart =NUL)
Eemp
next
newn0 de
printE n_Ho No deg OMe e i s
e se
-ce tuT

d o
is_not aamiddlo
poindE n Position e l se
positi.ao as
4emp= Aod
mp rey
CDaleleNodo a he Beot while emo ne-zt) NULL)
Yaid Del.beq
node emo
FC8tor NULLD Lemp=em nex

List rex ene NULL


prindf l n Fmpt
freeiemp
anif n Node ele Aed
else

emp8tcyti yold Del-pasC dle lade AT he Indennediele Postisn


SToc emp nert
foree Cemp node t enmo oYe
prinfln Node deleled inpasnodeCt ety

Cstar NULL)

Void Del. end C)Delo le Nada A End


prindf C n_EmotN s+
node emp prev re tunn
Page No. Shrikent
Dane: Paga No.
Shrikant
Ly923 723

else
int moin O
Position)j_
Enhex
printE I n int ch
L PoS)
E C dCounthede cysc
Scon
hodecis staD
prirdf\ n ***E Aenu * *** I " )
iE CPos na decir) pintEC In. Cre ote SLL ")
Dintf \n 2 Displo 8LL)
node daes ror
pindfI n this prin F C In_- n )
eXISiS porindf \n_ rderd Mo de A the beainnirg )
pintf 4Instu Node A he Fnd "
aL Pos nodec pintE
F C n S,nsert Nade A he nepmedice
IFCPoS
e Position ")
Stay pre N prindf C in n
He rap
while Ccty pos) indf n 6 Delete Na de AA ne Reginnina
ocindF n 1 Delele_ Nede A AeEnd
Henop prey- Delee Node A e Tntexme-
emp emp next dode Positio
pindf n

nent mD nert pindE n A


preN
rcee emp) priod Cn Enkty YGUZ ho) ce )
pyind C n lade Delede )

ese
Vod noin (void)
mintfC\o o Tnvadid PosLion
ind ch n
Shrikant- Shrikant
Page No. Page Ho
Date
723 Date
4723

Case 4
, NodeAL the End
while C) Ing end ()
brecuk
oh= menu ()i
Swilch Cch)
Cose 5 InsetNade A he
case i recde
SLL indeme diole p.ositian
E C S t e r t = NOLL)

P i E Cn Hou onar
nede e
CUont
cose G Dele Be Node AA he
SCounF Ld en)i beaienirg
CYeade Cn ) De heq
ed
Linked List bek
pzinf C'lo Sngh
Omeeled ")
case 1 Delele Nade od he Erd
else
De end (
xeck

priniE Cn Sinay List To


Olocead Creoa se g Delele ade o the
inke medicteposi tien
b-ce ck Del-pag
hre ak
CaAe 2 I
In9 heo
tlado 4 4he Eoinhino
Beainnira ASe 9 Eiie
ceaki

Cose31 Displo SLL 3


Displa getchC2
/ Page No, Shrikant
Date Shrikant
4723 72.3 Pago No.

Date

culougli
Singly Cy
lAP to
mpementa
odion s Cre al
2 Follo talng
aper
in
list i t h disploy 2 node newnode
SeorCh Co no de emp
eragth nodect n

include 6tdio h
2Std lib h nes nOde qetnode C
Hinclude
F CStomt== NULL

Sruc cslin k list


stGu neunode
int dosdoi
next
txucf Cs link list else

pedel shu csn kis+_node emp E Stor+


while Hemp next e NULL)
node stomd NULL_ Mp temp_ next
ind node d emp nert E neunode
node getnode

n6 de e n gde netwnode ne tor


neuwnad0 (hoe ) maMoc Csi2-e oF Crdde))1
printt C n Eniez dohet) Moid Displo )
SCon F C d Lrewrade daa)_
Newn0de nex NUL ngde e mp
mpStort
Ontf l o Sinaly Cizculag Nnked List )
Void ecde_(int o) IfCStort NULL)
Page NO Page No,
Date
723 Date
L4723

Empt
List flaq O
n
polat

else
else
nen tot)
while Cpas
do

emp doda)
intf C 3d
Leap Hemp next
while emp tor pintf C\o Elemen Found d
poind x);
leLao

oreak

Void8each
el se

node p-i laa


fHeNa =0 Flaa
pto 9tor
1f Cpts== NULL)

prindE C"n Em pty is+ )

else

printf Cn Ende he elornerd uhich you Chnif n Eement No ond 12


wan Searh )
6conE CN d" Hem)
iF CStor doda iler

prinEClo Ekmer fovrd od lo codfon .d ;


Poge NO. -Shrikant
Date Shrikant
L4723 y723 Page Na.
Dut

int ch elce
MENr * *
ln1)
paintE C n t**
Oindf o LiS is Aeod Exis
mintE n ),
iCxeode olist breakL
pindE ( n 2 , D i s p l e s t h e ist
pxintEC n
p i n t fCln 3
Search
Exit
Cose 2 Displo dhe list
aintF Cn H Display C
pxinif C" In_ reak
Ur c h o i c e : )
pminiEC In Enteor
Scont d " k eh i CoSe 3 : Seon ch
e t u n chi Seoxc h C
oreale
yoid malo CYoid)
CoLse Ai Exia
int chn exi Co),
c Sco c
whi le_C)
9etch ()
h e nm-eno )
Sui ich Cch)

cose Creode olisà StorFs NUL


Oindf nEnken numher o
nades t epele
SonE d An)
CTepe Cn)
prindE C n LietCzenbed
Pago No.

Date: Po9a No.


Shrikantn
4723 4723 Date 1

ned node ight NULL


o u bly i n ked .
ceunn new ode
SET:B
lementa

21AP
C a c a l e

o
a n dim p D h p a y a p e r a t i o n . .

n ked_t
kAP
Eglawin
fe
lpaplement

p e T a l ien.S
oDauby

9 Creae
dsplay e)
() istul int COuntnode Cnode _
f C s fos
gtomt

EENULL)
insert C)
de le le C)

include Stdio h else


inchude Std lib.h)
vetun Coy tnode CSaxf sig ht)'.
Stuctdinklist

vod Cxeode in tn)


in t dote n ey
leA
Stuct dlink list ne
Struct dink liSt
TBaht
no e new no de
Structdlin klist no des na de a
pe def Eorr 0 , 1 n s i4)_
hode Strat=NULL

node
qehno d-e= c ) neL n.o de oetngde C)
F or NULL
hgde nenMte
ne node Cno do mokloC Siae aE (rde SAT newnode
ntE nn te doke
Can d " Lnew node doda ese
henode e CNULL
temp to
/ Pge Shrikunt
Dene Piugo No
m3 Dato
725
iq ht) PrinHEC TheCon end oE st Ci9ht Ao
ahik Cicmp hdi
LeFA )
Lea P
emp
node Stox NUL)
ight n e
emp
demp
newna de le
intE

else
yoid Tavexse C
whi le CAem daht |= NULL
emp m gh
nade emp s
lemp Sto o R. whse CAemp NULL)
ContentoE ligàCeH
pindEIn The
i f tozt NOLL)
ntE 5 d ttmpdole)
List emp tmp e
polniEC n Empiy

else
void nS beq
whlle CHemp NULL)
no de newnGde

int C J,dd ca D deda ) ne wnode aet nade C


NuLL)

Eneungde

yoicd Re Tar erse C e se

ew node YIght E Sto


node emoi Sto l e t newnode
demp s0ri
Pege No
Date:
Shrikant
Page No.
Shrikant
723 Date

S t a tn e w n a d e

rerindE oF0SIEiGn is Qut a arge


Ye lurn-
void InS end 3
Pas nodectr)
em p E CPas ) \ c
newnoe
nCde
nenode ge+node 3
tempe Starts
iT (Glede Nu) pas-D
Stoyt neunOde eap emp maha)

else
newrode > \eH=emp
mpgtat newndde a ht emp ng h _
=NULL
Cwhile Lem p Toh
emp= emp Tia h
emp vight ne)node ele
hetwna do e E - l e mp
gnant \ e Posilicnd is nt nddle
vold nS poS C)

node newnode Lemp Void e bea C


n t pa node C cz
new nOd qe-tn ade O nade temp
printF a" Entes PasAHion Start == NULL)
SCCn f d Pos)
hodeCt nide Coundrode stort) f Cn mp tist
NEpOSnacde ctm )=9) aech
Pege No shrikants Pags Ho
hikan
Date 723
L223

pos C
Oe
Oid

pcs nOdecEor
in O
node Cmp
slse. E CStcc NULL)

c m pS t o o t

StahStot l h
farinlfC Emph List---
SEot le NOLL
g ect h C
ee Clemp)
yetyrn

elge

NOidDel_end C
pintE CIn_Eniey oasiAlan )
ndde
1
lem p- NULL)
Cstae
Coun F c1d,_pos)
nodecf COUnd nade CstOot
List- ) ECpoS 2 nade ctyD
mpt
pandEC o
aef ch orit n This Nade Ooer Not
retumnl

etch(
else
YetuN

while
em ighd NULL) Ceos 7 oa nodecix)
dem demp qh
enpleH ah NUL)} nnp Stoot
e e anap)
dena NULL wil-e POS)

Henp empia ha
Sheikant
Page No.
472-3 Date
4903

pintEn\a.

let pintO\n Tavese the list Cleft Rah))


demp 2
e m o i g hd
leP
ht=emp
ah
pindEC n1 avece Ae list (Rinht o eGt}
2iq
l e m p l e f t

e e Ciemp)
Deledkd porntEC lo 10 Exit
pmintE
n
Node
poictF n ONeuY Choice)
d leh
Scon F C
geturn h
else

Posi-in
nvalid
id)_
mind
n Maid main Co
aedch c

clh sc C
hie c)

hE menu C
witch Cch)
t ch
Cose1 Creole DuL
Ceade DLL " cindE CnEnley ho af nod
pa at n
oCr eade )
indt n-
TAStrtN de ot Be in
Beanaina Scanf( a k n )
indEp oEn
InSer Nade Crette Cn)
Aaiad n 3 pintECIn List Crealed.
mint F n
InSert Node al intermRdiole
position )

paAiEC n $. Delkle_Node_A The


Bealanina s 2 isc A he Beain
DrindF Cn . Deele Nocde Athe End ") InC-bea
prin n 7 Dele le Nede A The Inle rmedio
le posi fion )
POA Shirkent
Duse
723
4723

End
/Insert
A Case D |Exid
Case 3 Ins-end C) e Co)
b r e a k ) 2 -

ndemel aet ch
I r s e t Al
Ca3e4 Zns- posc ROS
x C o k

oimplermentO ub cizula ist t


eginnind AP
Delele Al Cond Disoko aperokion_
Core S Del be C b irculoa list t h
4) AP Ho implem en a
hreok
fallawing coexalinn S Creoe cy
End4
disol
LDeke A apoend C
CseG Del end C) delele C
by fak
include gidio h)
Cose1:/Dele
te A midiole include id i bh
POS
Del- eos (O 3Tuct edlinklist
hre
in d
Taverse ist odliakli st netbb
case 9
Tacverge ( Qtrud iaklist

brecuk

Cuse g ravese isE (Reverge pe de StucT CdliOklist_nodre


Rey averte node tot NULL

o de *aetrode ()
Page N
Dato
Shrikant
4723 hrikant
Lm3 Page No.
Date I

3ta pey ne nw pade


hade newnoe,

(nade
)_molloc
C8I2-ea f Cn ade ) S t o t 2 pey eunode
nesingde rlada )
pxind n En der deka
neunode
Scon
e F C " dp x e y
wnode NULU

nextE NOLL else


newnode
retum newngde
DrntE n_List Abeady Exist
yoid Creode Cintn

Void Disple le E ig hd C
Int i
mp
no de New n Oce pade _ erm p
= NUL)
DE CSfayt

E CSt NULL)
nodect =n
Frs C i 0 , i i n i H )

getnack )
neu nade else
iE Stcrt NuLL)

parind \n The Contend af list


Stort ne no de Pintf '), 3d dem dokt)
newnacepcey _tot
AeaD emp nent
ngwnede ne 5 tamt hile Aemp stat)

else nd C d emp doda)


OCunode pree StoP prey
newndde nent s t t t
Dalo e No.

13 Date: 1

472

left)
else
g nt
isplay

Nold euwnode 2 peNESTOk S pr RN,


n a de emp- neunOde pid-stas

sto 2eY ne eunade


NOLL)
= Stot eV neunode
i fCstond
p m a t E I n Empty liSf gtAN hewnode

ese Void Insend)


0 1isf
Content
The
prindE C L a
nade * neunode
newnode aeknode Co
e ttmp reN Mode c 7 T
Hemp dede ) NUL)
nointE 3d sto
uhie Ciemp sta

neun ode pV sond

M01 Tnsheq C)
Mewrode nent:stoyt

node e Aode els


newnode ae ngde

hodectm
NOLL new o de pre= ctan rey
newnade eM toà
gTo s newn0 de Stor re hextned oode
enade Ston rey neunode
newngde ent S fonrt
toand \n Hahe Tnsrle o End
3
Page No.
Data: -Shrikant

void InS Pos C yn3 Page No.


Dale
Shrikant

emp pYeV
nede newnOde DxintECa. Pasiton
ld isS not
int poSctr el niddte
newnade z affadeO
Enter Posi tion
); Noid Del. becq C)
pTintECn
ScanF d POS)
node enap
EC POS- nodecty 2 2
Stay NULL)
pocintECn Posi-ion is out oF
retun n
orat NiotOaNe ae ist )
9etch C)

E Cpo S kk_poS =node ct


else
temp= Ston
uhie C ctz p oS-1) node c t -
E Cnod-ec tz =0)
emp demp net
t r it
Sioct s lULL
ye wnace prey eiemp
newho de p t r e emp? nert
et rey E hewrode E
Hemp
emp nerf newnode RnpE tatj
nadectar t Sta sta nert
mp prey nmt STa
pain-F n Node ingemried a mddle
Stah prey emo prev
else F t Cegmo

inE n Node Deleie o


Beoinnig.
Dale:

C)-
Yoid
Del-end yold Del o

node emp NULL


=
Cstant
Exif Yode
I nader Cston ULL)
Mo
C"In
Printf

ge-tch C2 intf n no odas Ekist


getch Ci

else else
no de c f y
pintf n_Endey Positlon 1)
i Cnodecf 2
gconf C d Pos
yee Stamt) F CpOC >nodecty )
Stort NULL

ese YetUn_

emp 6 t c t
while tempNerP Stort)
tmp emp henft
Mp2 prey tetmp
next nert em oe Stoyt
prey E mp Jhi C Ctn paR)_
demp 7 neri 9
Pree (temp) npede mp ext
End.)
pmn ln Node Deleled Prcm
723 Shrikant
Page No0.
Dat
ae

peV
prey demp
emp
nerf
next e p
next, pmintE C\nl Delk le lode o Ln bxmedtcle
pvey
femp 0sikionS
ee Cemp ) orint F CW\n
n Nade Dele ted pint Q\n8 Displou
intE
nadecfx
xiaht
mnf C 9 Dip lo Lis n Mghd do
else
Position
n Invalid
rlntE
aeich (2 int f Enke YoUY chaice )
ScCunE -d kh)

n noenu O Nald maie (vod)

lad ch S int ch n
c Sex (2 * I n 1) clascx C
* MENO hile C
prin Cn
AintF
. (vente cha menu C9L
riatf Cn
ind Cn gui teh Cen)
n niertNade 0teaioning :
oTE Nede Ct_Cnd 1
mind F n 8 Trsert
ln 4Insert Node ntemedicla Dsintf o Eneg nof rodes
mitE
2ositi cn
irmntf n- n gComF dkn)
priptEn S. Delek Nade ot beginnita
pindfIn 6Dek No de e L )
y723 Page No.
Shrikantit
Date:

Case / InsENÉ
A egina in
Ins-brq (2 CeLse 9 | Displo ist CReverse)
Displo a n t . \otA C
hreaK
A End
/Ins-er

ge 8: Ins-end
ex Ca)

At i n m edlote
dlole Posi
Tngert getch _
CoSe Ing-pos C
breoukK

Case |Ingert At Beginnir9 SET C


Del beg C
breae AP to find ouddiion o Aua pa namiols

cose 6 /Ensert
A End nclude stdio h)
Del end C) includeAStdkib.h)_
hoceak 2_
guof liak
lo4e 7 Delele At inkey medicd Posii
Del-pos C)_ Floot CoF
hr eauk i h xo
SArUc_ lin K net
tose | Displey lis
Displo LeEt_lght C, pe deF Struct a k node

break nade Aefno de C)

node m
713 Pageh
Shrikant
Date:

)malloc
Csjze fCnode
PE Cnode
emp Coepficien
p int n En ter
FFlush- pb) (Stdlo)-

Cog uhile emp nert ENUL


Scan F (
pant f
CIInEnte L emp xPon-emt");
emp emp next
Jerap ent _nelnade
Eush Stdin
.d temp 2Expo_
SCant
temp nex =NULL

retu emP
Noidisolo Cnade k)
Csecde_pey (node p
nade
nade =p
whie t NULL)
choych
emp neLunode
nade
in C t.2F COeF )
LWhie C)) poinE d " exp)

Do yau Lomd
pobnamiaucul node Deri
nat o
yln):
t h q e fche (2 Cnade *pnadep2)
i EC c h = ' n ' )
Void add n

node y newnade
bceck while C)

neuwnacetgeinode C CpiSNULLI| p2 NuLL)


iECpe NULL
orcen
newnO de
Cp expg 2exa
Date Shrikant
23 Page N
Date

Coer
)dP
2 F x CoeF Pa expoD Void m ain -
d
printf

pdpi nezti no do AayENULL po ENOLL pn3ULL


p2 p ? net/ Clrsc
Oint C Enita YSPo l nomia i n ascendino.
ding-
el&e
paly ee
expo)
p2
expa
Cpa
CoeF.e paintf C n £Enter Arcond Polnamio in
)d Pi 7
pintf
"+2f_x
oSCendina rden f ex pon ena):
poy2 (eoueP0 poy 2)

in C\n Enlex Panomicl


dp2 Coe p2 display 0o
. 2 f x1 d pAn Cn nden Pobhnon jal
DindC
e2 p27 nez
rintf n Besul tond Panomial
add po y po 0oy
disploa 31
whie C p L = NULL) etch C

P12 Coep xD
C" + . . 2 F 1 d
O rcin HE

l= p ne f AP AP 0 on cakenode wo liak ea list

tuhie (p2 NULL) ude S t dio sh)


incude alih.h
indf 2 x dp Coe P exo
t
gtru ne
Date Shrikont
Fage Nc
L713

St pode p
ink
S t r udeta
c th o d e nert if CStor1 NOL)
:
nacle
Cxcale
Csiruct
sto 8tort Stort 4
node
Cstmuck
Sxuctnade

Cancctt
node btot 2)
Sta EtumS0r
g u c h a k e

o
stauct n Cstork NULL)
a d d -beq duka
hade
orln
te
8trucf
node_s

add.end S tauet reiin Sto


Shuet
hode data)
Stax
Cstouct
nade pt stort i
void Displasy

int maln C)
NULL Ston
Stod 2 NUut
8to
(Stort )
9ruetnode

(recue
Stard
CStert2)
tor 2ECrede )
\ n Firs
hs t t
pritf
Display (Stagt in nda
lig i)
Secord pxind hi rEumbir adg
prindf h
DispbyS Hayd 2) tor2)
8tat Con Cat stc Stort NULL
list k , i CnEe0)
pmindl" n Concaled
Disolaytort 4)
retun Stort

ghtt nade lonCoStut node Staud 4 Oxindf ( Enhez Ahe clennd o be is


4723 Date:

a d d lseg u pode start


9t3uct nade
k_dede ) ndaded
d deke
sconF C 6ttT

Odd-be
Staact
truc pade R e in
te,
elemen
he
ntnta
Aade\
pzind
s e l e d " 2

d e d e

Cattot
couta)
temp nen Stoy
adden
gtoot C
Yet Sic
x t a n 3 t o t

Stat node pddend ATuer_no de t


Stuc ade
Vold Dsplay iddaAa )
p
Sdru cf nocle SAruct de * o ao
i Csthrt NOLL
Hemp = Stouct node *\mallac ( Nze of Stzuctrode
pindFCn tmpty LS kemp dla dodta
retumD
hie Co eNE \ NUL)
ne ti
C AVLL
uhile
Aenap heret NULL
pitfCd pdeteO
pp nex

amiatECn')1

6truc node Add beq Cs tyuct nade A Stued


ind douda

You might also like