Ada Module2
Ada Module2
a simply btude-force
to Combi national
agpioack
eang
thoe them
sleckg
elaments
veATts cach
that
where
bnce
cty cady
tt sarted
Pto Lem
shortet Hamtttonan
Whehe
To uY Lngt
la+3+1+5
a0d ba
a->bca 1= 7t3+ 8-+5 23
knapsack roblem'
problam alyoAkmiCA.
other ell KRon
a cajae
values V,Vg Vn and tnapsack
10
ffcm&
Total value
eig Total
$42
3} $40
5 425
\0 F54.
not fastble
7 $52
$37
4 not feassk
15
2,34
23,4}
t
ongueh
Dékde
to the 4oloony
A prollkn
i dvtded \nto
to
alout
Aame
Aowed
The
subprobla
m ast
Con)bined
to ged a solwdio to te
QuiCkso1t
me elemert
al ke elemend o
that to tht lat
and all tae
A CSI Qhe les
to the gkd 9 A CS3 are
lemenss
qua to tt!
oT
ACs] tll be
paath on achetved
Aj la a
postton
an
Se Parttoh (A C4:- Y)
Quicksort (A s-I)
quick Sot t (A st-1J)
pacitfon
(A[l)
Algockln demet ad pivot
subanay
lpantions ACo-n
Il Thpe:
: subaat
paattton
AL4. postion Aetusmed
loipat
P< AC
Yepeat
untH ACUJ<P
Yepeat
j
AC31)
Ssap (ACt],
Shap (ACl3,
AC0s
3 4
5 3
5 3
5 31 4
5 3
5 3I
3
NOW solye
Subaa
vdually
lgH sabaMay
A 3
3 4
&1 3
12 3 4
the wtth
COm bene both
NON
in the míddle.
damad
Plvod
2 3 4 57 sorted aMa
and Relaed
Yavessals propcrheu
Binaty TYee
tyee
A bluaky te
etltek
A nodes be
hces
knaky called, spekivey
too dyjeln
divtdes a
ttacl
Stnce
the dame
tre io the Problans
&ubtyee
A binay hee
Sandard repesentalioo
tre. Heip
to
the TOot
patt rom
4 the lonqcst
as the aimum
emply
bee ab -1
Ayotim
Jcomputes vecuYvely te a binay
else tetusn
vnade
The conpakisiow!
numbeyd no
Ue
A
maimm
CncT)) made
by t algotkm
ale
))t A tIfoY
n(Tag) n>o
A(n (T))= A(n CTiegs
emyty
by eplacing
tree ch be catended
called
nod ed aYe
The cxtya
nodes
by Apecial
Aubty us
nodes (côYeles) are Called
extesnal
Lninal B dayintion,
node
0-nenano des
nodea
(4)
lancion cb).
eztnal nodeb
num bes
Chan
te nmbe nteanad noded ne
bot,
NOded
T0 4al no
nt tn an t|
o1 too chtdien
Aas eek 3eo
3 clauie tyayers al
binay
traveAg al st tae
Pre ordey all thsee
inor dey tree
nodes
Post ordey
tyees roo
kubtree
Preordey thaveasal
ughd ubtree
(LRR.)
Preorde
abdgecf
nordet- dg be afc
c a
postorde ?debf
Post oYder
LRoR
In ord e
Postordey:
L0 52 LR Ro
15)
Postorder; DFE 86 L Jk H cA LR Ro
LRoR
DBPE GcL J H K
TH K
norderY
:
9: 8 5
postOTder 75 2
93 10 4 I6 5
clamnd
Construt a BST for below
27r24
20, 23, 13,9, l4
19, 2-1
(20
(1
Multspliealion
metthod
fof multpyh
ach tu
tnteyes,
mudiplied
numbex
frst
Aecond hunbes
To
luey
cong
-and-
divfde
as
prsed
a = a,ao
b= bibo
Co
ohere
bj 4,bo5
(2+6) * (4 t+5) - (9
t30)
C
C- at b=
8x1o4 34+
xl0+3D
I|o
80D t3 40 t30
Time complexty
StepI
3 41 Hu
huL
L
3 HOL
C)+ foy,
foY, add, &ub,Ski
Mn)= 3 M time used
opuadionh
= 3 M()t Cn
mas tex ltzoan
Appy
a= 3, b 2,
3 1:54
2 fen)= n
Caaymptott cally)
b= 32a
mate
&ame Sizli
a,=l2, a 12
b 03 b 22 Ca 12 * 03 = 36
Cz 36 lot
Stassew Matri
4 Gu in
alyokitkia
The
wl
the that
dlacovely
wf th
kuguired
to by brute -fore algoxling
oppoad
d
aco mpitke uing -folls wing -formula
bs 2
Ca
oheye
Cal
Ca
-baa) AI (Ba-84)]
my
aa(bal - b) Ay CB3-B)
a) bz
t *
3.
in
Apply
alphabci
insextton
cal
sort
order
to
soyt
G
c,o,N,
,u,
C,R
1
(1t4) (+2)
215 C 4-5-6= 5
Cm,
a-1t4= 5
I(-a)-1
Cy tt +15-7 = I1
n6 = (3-1) (1+))>y
5 5
n o)= 7 H()
fen)= n as4, b
n
12| 624
31,57,
be non Malive
Let T(n) dned s theL inteycu
YeceuY anle
b
T() QT (E)t f (n) hee
>
al, b>l be
a constant a fen) be a
a function
Ton) can
fcn) = O(nlb
be
)
bourd asymptol cally
for Aome
as
conglant
Jollo
eso
ot
bijex tia