100%(3)100% found this document useful (3 votes) 281 views17 pagesDAA - Assignment 1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
4
explain Asymptotic Mototions wit,
ilostradiens
oy consid ring the Plousivy
xOntply.
w*FSut] = OC, Sntantro zOCht)
M3 FY4nt =n cy > 3n'F1 coe)
asymptote MotaHon yg ten
oN tay
otofements Oubout in¢ time and
cammplesities vi aun Og outhny,
The MAW Ida OY Asyeuptotic onolly sis
at, hove a Moosune Hetenay 4
aiqaitirus thot dorca} depend ay Watching ~
specrfic Constants, ang doesn} Yoquing
alqerithnay to lox US Lumande oF Hime Taken
by proqronn to he coucpiutey ,
exonple Ost +Sn7- Gene)
TAS eX QMPLE Uses 8Cthety) YOFAH on.
2 The 8 votad on binds o Rn chiow Prom
TF delings exact
Space
obove and helow, so
osyetptote behaviour,
“We CON Get Tha nob,
by clroppivy ‘ous Ordon Teams
Leal of coustounts-
* 869 cw = $C: Mane ast Positive constandy
S11 C2, Od Ay sveh that 0 S= et 9th ln)
© GQvatn) fer all n>z M6}
%{ an “xphar| on
ound iqnouy|, —
Tn this exaupl, gu 7n* and ftw) en)
>+y £n) = nb4sntT 1s theta of qos
thon the volue FCA) iS asuso44s be teen
C1¥ gtn) ond cat gen) For large vodues oy
W Lhe. APN].
+ F(n) wut aso 'e non-negative for volueo
of nv quuorer thon Wo.
Were’ Ot que ef s a FV
eae Ueye < MeasntT ¢ Cot vw
[esseme wel) ntgsuerzem. | meSMTTE Gr
oe Re B7¢, 1442
Gel ey
FO) rpnete(ger) yy a
@ Snr +3nt20 = 0 W*)
«The above exoniple uses Big © notation.
«Tk Big '0' notatiou, FU) < cA. is tre
Condition where FCA) abd gi) our, twos
| Functions and © if @ COUsHAHE.
> Sy2r3nt20 = OCK*)
tao FUD< Smetsntz9 , gtiorne.
Sr243nt2o < we Cent |
yn | ce
SHO < C1 a
Wecy a
C28
vrxt
oCut)er |
o ore 2) 5
THe Above example Uses Oussg of *L) notation
pte condition for RL notati cut, given two
Pynctions FCW) and qt), is Mn) > Dorginy.
for any PO) = LO GtW).
. cousidexi vy the Given eKanmplo,
p3tun®= 420»)
ne time 2 nhig
Assure uy nz)
THU zoe
@ CES. C2S ney
1. OCnA
@ 3n* +1 = OCn)
+ Me Above exanple Uses Rig ‘0 notak on.
CT Condi OM Rey Big O notation 1s
AW) = cq whare PCr) and qu) ane
tuso PuncHows and CS a conotanh.
3nrti = OCn)
PCW) = 3G, queen.
By Big 10" Moth om,
| an FL S Ree
| Assoun vy wel,
Yeua i Oulgenitts nv Per its
G2.) Araty se Ws Quick sort i
Gvve rage case ferforante wilt axanple,
2
Ae (BE 81,22 48, 13, 64,13, Me YSs 981 79,7 »)
) sverage CasekTime Couplovity)
TH) AHL ZTE TM) 2B
Keven
MUL ply Both sidis by "it
Me Ten) a ntwt rg s THEI) + TEA)
We TH) 2 ACKH) 1 ETC kK) tTCWC)
We TU) + AINE daa Taye ETA)
> Put ne wt
4~ (rin4yj = OD Ong ia1y #2 (TED te.
+ TH-t-19)
. UY) roy +2 (70) tT) +547 (2) |
| > Put wwe
CY TM) = HD UH Hb Creopttoie «
#729]
MOM VETO) 4 TU) Ree
© T(n-39])
> Put © 'w O: |
MTOYE (mengtndy -
UMD + Frey en
TU) $ 4TH
= 27 fot Ty “Teng i)
| WeTa) ? On-tyttnaty ong Tn
WT) 2 NET Co) hen) Tet)
W2)Tin-2) = (y) WET) Catnty
TH, /
‘ 2 AhttnIfnHy -@
wT
TW) yk THM YI
rant) ydntl) Koen
To 2 a, rend)
HH) gat) | pats
eS ee cea,
n w ny
2 SUbsttute THD jy ®
oe
+ Te)
wut ntl a
| [2+ tow =). i
w+l ont nt
> Pur Wt W=L jn ©
ery +The)
W2tl nat] ra
De a rns)
ut ny mire
7 Sobstitute Toray gy
h-y
CK)
2 242 fe
A Thao)
TH)
at RED pte
i amas 11)
RT ey
aez 2s Lyerys
gexen i)
i
"as " dx
2
7 2tn4) [ tg 41 - !og,2 )
x OC alogn).
o Ae (38, 81, 22,48, 1, 69, 93, My 4S, 58,79, 99)
1]38,0=72, pit 38
ati p Sing i,j de noforrss, |
38 $38 Swap Wg) >
resis @lity)
8133 SBIY 22. UR 1B UG 93 US SS 772
False; i stops 9.7L
22.438
ps ony my, tt
eT Yee 3
tres ye Foe; C stops
AE 674 26493,
~~ eee,
a82G
ae thas
Wego 3813
asus oases} stops
tues fe > swoag inj) ~ (485 19
"Bey
Pouse;J stops38: 1422 HE Gq 93 B YS SETI 7D
ALE p
YS Sas
‘Aalses L stop
p eat) /
SL 13,
falses j stops
Se Oj cvsse, suesp (jsp)
131472 38 Ys GY 42 S| US ye 79727
Pivot leit + agai
VAnvay 16 suldi Vie simer the pivot ¢ lene
charged
: ei + Subanay |
B IY 22 By
Be 12 (S22
rt ary Jo >
sucid VSety
Foules, i stops MRT” *
WL
oe yd
7 Sineg t ernsse Sy, swoop BG) Phot).
(Q)M >» Bs)48 6993 8 YS sB ay 72
Wwyety tyerr
tte stun; je
arty eS 1y
fouse 5 istops- HET swoap Cf, pict)|
|
|
|
|
08 [eTaa3s] 48 69 93 Fl 9B S8 799L
4s cus
wey itt
‘
O9< 48
False, stops
Sine
US SUS
tie, ee
Use ue
trues itr
93£u8
taser ‘steps
G8etr
ney; j-~4
48279
tue, p> >
WS S55
“tes J -
Uscus
False ; j stoy s
14 do wot cross, swap Ci p.
Rete TMT] us us 93. 9
69 S879 12
Tq usus
Hur, pes false; j stops
usc79
tus, yt
West
trie; jes
Ys Gy
true; der
YS < 9,
tre, j--
YS£ 93
tay j->
> Sik UJ eet oss, swop Hey CG, pivoh.Baal ax. tl G4S3 79 :
a fF ‘
pi
93¢ 93
ches, tt
9293
trees itt
qed
cue, bt
see 3
chug #H
T9ET3
tay itt
2 aad
ti
| > Snap G4 Cj, pinot) sina yy CvE85
| Bea os 79183
I ay 4
Ee v
ceo 2279
tes ite :
= ney j-~
Z
ele yess
Kee) s :
Folte} t stop fouce; } srops
a ie
2 Swap Cty) sinw t, j do not Cross «1B) FF) fae] fae] HS) 1B] 72 se 69 21 79183]
OO "
Pi ‘i
a T9474
“Huey t+ Cae
a neg)
Ty ttt “tej jo
Gas TL LO}
twee, tH false; stops
NLT
Fale, 1 steps ar
> swap (P, j).
U8) TS) (2) Ba) GH) AE) og se iw)
09664 uoess
ey itr Pe stops
38 £04
MR itt
snap CF)
rs) A) wy 138] fs] BBA « 1 5
sy 7 |
tye, Ht |
79£3| Fede stopsy |
Tie, it i |
| > SWap Cpr)
EIST B) BBS) BR ala my
=res
Ss
jorile 01” oq citar fey merge sort, Sart
52, Gl 1 22, 3d, Hy 22 ia si Obove onting
'
yuttrod R
S
“Aig onl ~ Merge Sort
|, Migonitions Merge Sor{ Clow, igh)
g, Ho Clow: high) ico gina! MOH to be coreg}
: swo(P) is cing Arne 18 ME ry Lorre;
y. to sort: ®
s. 4
GF Ug tog Ar we boaTM Bayar!
NeTCMaw) st Pgrpar gas 42
gel
Wh rOd4 Janay as sang
aloigny |
7 My 4 [ eee]
TMI, 4+ [argh 53
tM
a en
2Salve Strassen'S Matna UL PU cab oq by
9
cousideal vy} ony aX2 wiatiy as lupub
Aw An Au An,
. 2 ae
| 4. [: me B ie a
Ay Ady Ay Ay,
P= (Aui4,) ton +B)
>? +B) ( tty)
Qe CA +4) t Ba
7 Gtyay
> TH
al, |
Rz Ant (Bn ~ Bary
u 7 (2-1)
~2¥)
Roy
Se An* (B21 Bi)
Be (2)
ry t|
S2y,
”Te (nti t Bra
tS #1
TS.
Ut (4a 74) # (BN + Bid
*@-grt (l+y
2 1NS
UrZ.
V2 Anne Any © CB) +809)
r(gr ue h a+!)
74a
vi sy
Cyt PES -TH
rat y-S-3
(C= 8-
SU. t RIT
L+S 27
(Cr)
7G) x ars
THY
(earnoe
7 Car =z P+I2-O ty
+ 1242-73
"10
}Ga 10
————
Ct ty 3
2
Cy Cay (I t
1