Professional Documents
Culture Documents
Adobe Scan May 10, 2022
Adobe Scan May 10, 2022
Data Sauctures
Set af aues.
Data
means a
value or
dafa
pafa SEvuckure is
D a f a SE a
ay of soring G ogangng
manner
efffcient
an
n
of the daa Su ckurse is £o
The matn ofectioe
The e he
Sore oetrieo e dafa im
effectiuelg Pientty
Mathemolcal ,a daa sbucture D is a 6ipleE,
D - (d,f, a) f= data object (see asOamaetes)
fSetof fumcions
asecsules. lo mrlement-axbons
mefhod of.
CSassication DE-Based on 0ganizég dàta staudue
Dala SeotucEures are cafegoige nfo 2 ypes
oinear DS-
dala skruckare is Saiad o be 4inear f tes
Tfa
etemen¬s orm a Seaaenééal ovefer or in a
near ovder.
Ceraton
Pwesful booC in
Ke Cudston is an ampoatan& l
poolem Soloimg 4pvogvamoning
Recuvsion ts a progvammimg techmue thatmatural
mpleTments he divde Couer pooblem
Soluine HethodoB}.
oocer C¬eria ofa Keursie Solubion-
1 4 ecursioe fanction calls TEsef
2 Each ecunstue -fanetlen call soloes an denliCal
u t s m a l l e r P r obCem.
mase have a
m f n=o
f n>o
Destgn He£hedolosyg
The Statemenf that soCves the pro GCem s kvoo
as he base case
2
Ese
Eseng ecuasive atgo»thm must have a base
case The rest of the al8 thm S Knouwmn
as the 3emeral case.
Limcbatrons
a
on works besE when the alkotthm uses
Recurs TeCursion
data suckare
data Sfruceure
thal maturally Supoals
Toees.
fbonacei n) -
5 o fn-o 6ase case
fnar J
fkon)4 Pbo (m-2) Sena v
Lnea Binau Kecsion -
dinea Reazston
the mos E Comnonn e eansion in ohickh
funetion Ca11s tse geately untit base Cre Gom
teamiratlon Case s Teachedl. Once the ba se Cage
esulE s alle an etarn o the
is each ed the
funclton. I f a TecYSue uncben ts caled oml
S Called a lineas TecCurstOn.
Once then
fnding -factoriad af a
umbe
ex
Soct Cint S)
n&ain C)
nt a t
fact fact (5);
Pointf ( factooiat ts fodfact );
ePfactovtas ts 1a0.
Btnavy Kecunssn
Some recareie fanctton don't juse haue one Cal! to
hemselses , the fave t ( more):GunCeons wh
tworeawse CaDS ae efeoved to as &nary
Decnave fun ctionS.
ofe-
3
m s Db
1
n-D+ f?s(n-a)J
4Tb [o) - o
AStSeven
ba) Fb) + Fb (6) = I
ftb(3)ffb) +fbO)
=
a
Feltminanies oAlgoitfrm.
An algo thm a y be destned as
fnle Seuence
nsfructons each fwhtcA has a ctean mcaning
c a n bepesem ed w th * a n l e amount s f
effetm a ffn Ee tevgth af tme
the Aabic
he atgoritfem r d oviginat eol fsomn
which s nked to the mame
wod Agoris m
the Arabic, matfemiian Al Khuwanzm
of
He is Considered t the Jt»st algoth om
ubers.
desgner for adoling
Souckune Algootm : - 4n algottm has Jollooirg shuckne
Tput S¬ep
2 Assigmen E SEtp
3 Decisn,, 6tep
4. Repetitoe sCep
S.Oubpit step .
.
Algovithm peopeotaS
fnilemess An algottm must termanate ater a
fnife u m b e r o6feps
.
ha
akovithm musE be
-Defomi feness e Sfeps of
defined, ax
Precsel
be
Effeekioenat the opevabions of algon-ithm must
basfe, enouph to put doun onpenut G
should nof be too Complerc
pape +hey
uxant cocty an othe algooithm or
fo
he operabhm.
S rut-Out The algoithm must hae
a e ccetain
eai m
tn
oo pes
. To Saue tme (Ttme. (mpleiy) :-Aprgram at rng
aslarts a betee
2 To PO m.
Sawe Space (Space lompleay): A
Pogram that Saue
Space ases o
(ompeking
P am is onscolered
Tme Ccanpledt of an
agotttm odestalRe
na
a Prgrarm is
a
funcon of the
sunn time
f the alpooitm
apogoamTn other wodS the amount
Conmpue er ime t n eels to Tn t
,
Coypleton.
of
H increases as nindteAseS. tE S
usually the Take
afncrease o n w 6 Some Sfarcdavd fanckom.
he mos Comon
Computing imeg Qe
oCD,o(la,n) , Om) On), O%*),on®), O0n).
foag waro Sgment A Ps goam Segment B Pgoam Segment C
foo k-I tom do do
o to n
*t2 do
Jo = to n
end
Coune
end
equar ant 3-nt
h e toa! equency Cocrmk fthe prgram Sepmens
A,6C gan y 1 , (n4) G 3*43n4! ekioely
axe ezpoeked ar O(), OCn) O Cn*).
The axe
aeffored to time Complecitfes of the pongsa
segmen since ehey au indicatie of e unnng
ftmes 0t, the PoKram Sepmen k
tnkec tsE
> A Linked List s a inear Colectiom of olata
eleiments calle
nocles where the tinear ooded is
gioen by
oineams of poinfer
cach made ts dfuided ento oo
partf
The frcEparE Contains infomatien olement
2 The Second
Jaot Cantains akress o met dode
Cttnk/pointer[ fte ) in the fs ¬
he daba serg in the inked ts ane moE n
Adoanage6
These
These
aT dnamic odata Struchraes.7e.they can groy
or Shoink duofng the execution ofaPogam.
2. LL haue
effcient memooy utiuzaon. ttee
mem oy s n p e - ato Caled. Meme is aloaled
henever tt s equed t iE s de alocated
Csemoved) when it S no Conger eeded.
an be ea auied out
Harng Comper applcations
Mang
n k ts6.
Aomt
Cperafons n SL
The ollouuing optabiom oopeformad On a SLl
rsortien
Trsextion, Deletion ana Searching
Po need to
eehaeue fmplernenb ackun epexatiana
un
Thsertom
opaalon Can Be peroome en thra
check whether sE ts
Emply (head= =rkoe)
Stee?
then S e t head neuode
-
Steps If e is mplhy
S ndot mpey then , defne a node pointer Lemp
Step Tf i th head
and tnicalge
next node untit it
Steps-Keep mOving thhe temp to its
th st
Gtven rode is not fourdin
display cmp to neslnal
bthewise move
nseotion Ts nel poss e
Stepi fal See meuNode mext
temp ne re newWode
Dekion;
nSingke inked 'st deleeion pealon Can be Petomed
thdee.
9ays
Defetfng kom Beginnine o Gst
sC s emy head ==OLL )
Sepl
rpl Check whether
'LisE s fmpyDeJe
Stp2 If it 7s
Enyd,
Empey then di's poy
tesminale
the fur
is mo possiECe
Step: f * is ot mly then des?ne a 1Wode pointe 'Lerr
lernp
o ttialize uuith head
nde
Stpu check whetherr (ist s hauirg Dnly Cne
, 5 is havinP np
MAe D MOE
one
has only one eole thal s he node tu
T s
be deleted , then Set head = oLL E delete tmp1
eavchcng- ement in
list neans Eo fnl ootícula
Semching a
hd st- t s
Sap