Notes Dsa
Notes Dsa
Introduchon
Clossical Conpute only binory togu6ge
(,0)
big
bg 0' Omego Theta
cout<<: n ime
furs
Cose2vesge
TNoste Cose
take, 2 n ) = C=3
Ucoer bond
:nis irpt.size
wednesday.
Dats 03 O7
JAveroge Cose:
VC posithve constont
f¢o) = 20+1
fom)
loser bond.
8] 8est Cose
fio) = e(gco) fens Ci gcnfen) Ca gen)
loser
bend
Sort
L = 4.6,2, ,5.9.3.
2, , G, ,5, 9,3
!, 4,6, 2,5, 9,3
Paçe No.
Date
for n(o+)
to
exchonge ( Ltij,Lj)
E5
2 2 Gg/4 t 23 56 9
Ji+I5 5)9
Thursdoy
30M5Pa tio 3
Aito n-!
2 to n-1
i= n-2
£= n(n+1) +
n (n+)+n
n2+ 2n
avot^) =,(n2+20)steps
fio) =O9cny
fin) O' (n). Speedup foctor.
(Gronth of fyne
Naste Cose
is quodratic.)
\Sorting element
L=,2,3, 4,5}
for i=0
exchonge ( Lc,ZEjJ)
if (check fist)
(exist)
feny n2+
Speed of dgothn
DOMS Page No.
Date
O(ny
. Groth of progrom is
T(O) 27(u) Ca
Put in eg
T(o) 2 J (lok) + kc
k Jog?
T(n) = nT ( ) t C Sog n
ntclog.
Speed-up of algoithr is
Cn
.: The
chonge in algorith leods to
dro
change in
speed-up of adgori thm,
.Speed-up foctor K
rurime of algoithrn,
eie Speed -up foctor
Teo)+ = T(Ol2) +C
k zDog 0
T(oy
Ten)
Recurence
To
algathns
Put
Compure
(^2) T (gcn))
fcn) girenRelationsTP
T(4) Neglec
2) 1)
fen),9
e(g2?) in T(n)E,2T(le)tn. Neglect! therotico conputed
T(O2) (n),
T(^l2)+ :2 n2+ 20
(4) T
term"
lower
Constaotgrder, constant
+ne
eq() ,
Ca
running
(4) T Coeffcient.
DOMS
07/2024 DatJO
e
eg
’O(n) Poty wedoesdoy
repres PapeNo.
2h qur ot
(). T 5
ented
n.
DOMS
Page No.
Date
T(o) = 227(°/4) 4
47 ( / ) 2n
T(n) 2? T(o2)+ 20
T(o) = 2 T( /ok) + Ko
n T(I) + n
T¢n) =
log,n
This is Aet recursion
logn)
algorithm,
Master T1ethod
Tio) TENz) + n2
Condiion:
form of
T(o) = oT(nb) + fin),
ahere,
T(o) 8T (O/z) +
mhere b:7:
DOMS Page No. G
Date
Tre
Three Coses:te
) CoSe I:
0(n'
then
(:E iS +ve)
2) Coseo2
fco) ecoS
then
Dogn)
8) Cose 8:
log 3 0.5645]:e
Jog
0.5645 0
Cose 3
e(n,° feg n)
Tuesday
Ds 16
Algorithms.
Set of fnite 5teps/ stoternents
specihc seper Sequence to get ofgoriszed,
desines
in
poly nomigal time
Input / Otput fnite
tirne- bounded.
( Polynomieiol )
for ( i o to n-)
o
Sum SUm +i j
return Sum;
Constant
C,
DOMS
Date Pase tio. 7
Fon)
cgen).
Cigcn
Soving elemeots of
ist
Algorithrn Soring ( Lto3) Oscendin2 Order.
for ( i- o
to n-)
return
n2
2 2.
n2
-fcn) = Ogc)
fer)
Tuesday.
Date 2307 2014
4
Doyttioning
fred
Unsoted Unsorted
G52 15 8 9
Sml gretterthon
Povtoning elemerts.
if (P<r)
( - Povtitnng
9= partiion (A,P,r) inder of
pottenng
quchsa ort (A,P, q-)
qwcksort ( A ,944,r)
ohile fALJT)