0% found this document useful (0 votes)
11 views19 pages

Ada Module2

Ok

Uploaded by

enoshmuthyala484
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)
11 views19 pages

Ada Module2

Ok

Uploaded by

enoshmuthyala484
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/ 19

Ahaust ve Seanch

a simply btude-force
to Combi national
agpioack
eang
thoe them
sleckg
elaments

The probm eatA to nd te shortest touy

veATts cach
that
where
bnce
cty cady
tt sarted

The problem CAn le modeled by a

ith tae VeRACes tle cia


tAaph,

Tn the proten can betated ab6


tte

Pto Lem
shortet Hamtttonan

HanHanian crcut can also be dejined ad 4

Whehe
To uY Lngt

la+3+1+5

a0d ba
a->bca 1= 7t3+ 8-+5 23

knapsack roblem'
problam alyoAkmiCA.
other ell KRon

Gtven' tHemd a Knon

a cajae
values V,Vg Vn and tnapsack

find the moet valualk

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

Sinte tte no ef subscth e an n-eleMent Set =


Leadd to

no matte ho qe itdua sqbietd ay


DEutde
-
Conguer

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

(Qubek-soYt dvtdes acording to theiValug


the aad elemeats
A the

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

all ae ALS al ae ACS]

ACs] tll be
paath on achetved
Aj la a
postton
an

ALGORITHM QutcksoH (A Cl--)


soviL
A Lo..-], deqtned

lqt and qt indt caá 1 and Y

ll outqud : subaay ACl- AONed in nondeczasuy

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

tyees Can be oled y ppyng


about

A binay hee
Sandard repesentalioo

Led ue consdey a reouYve

tre. Heip
to
the TOot

patt rom
4 the lonqcst

as the aimum

Bhe heighdA e Yocl

emply
bee ab -1
Ayotim
Jcomputes vecuYvely te a binay

IDNud A binay tyea

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

suslyees viutted (RLR)

vstig Rigtd auste (LR,R)


baqoe

ughd ubtree
(LRR.)
Preorde
abdgecf
nordet- dg be afc
c a
postorde ?debf

Preos dei- o b dce


db a
posioes dbec a
ConStYuct a binaly

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

Lel a &bees ab can be

as
prsed
a = a,ao
b= bibo
Co

ohere

C a,t a,) * Cbitbo) -(st)


65=30

bj 4,bo5
(2+6) * (4 t+5) - (9
t30)
C

*)-3? 222-38 -34

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

C> 244 25) -30 o = 6o0- 300 =


30D

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

m, = ata,) (bntba) )aiA)t8,+B)


ma=

-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,

NAlah pooja, Loe4


Stey
Theoem- (used
div fde conguYe Techniyu)
Tne bascd
ound
an
Telatton
thdt mossey thesem
To solve elatton

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

3 34 4n)= n") for 4ometotfaat esp

bijex tia

You might also like