Professional Documents
Culture Documents
Daa 1 - 5 Units
Daa 1 - 5 Units
npvt
2) OUtpot
3) Delin.enes.s
4 Froiteness
sEectieress
Analy3e an Algohn /Tne
J
ime
2. Spa Ce
enp a - 1
3. Nelwonk [oba a -b 1
Pow b tenp-
S CPo Repisls 3
Yo):3
Space
a-I
enp
Sn 3
Asuptotc Notations
of lhe eficiency
T 1s sed fo
HeaSure
tools to e Pre Sert the
algeithnsss nalbetabical
Alpashithins
ne Conplexxily
Asynpletie nofatiens
nofabions
h'ade Hainly hvree
Bry-0 Notakion (o)
OMega Notsbon (a .
Treha Netaben (e
-O
T)O01) Oerel)
Me cunnence S
call f
when an algoilhr Conlain a secu NSNe
by SecuIIeNCe
Hsel, ils unning Me
fline Can be dlescr:be
eguaticn
These ae toun riethods to Solve Secu 9ence oelain
elation
k 2aK- +K fo all22 , a)
a2a- +2 k
2a+2
2x1 +2
ag 2agt 3 3
2a2 +3
2x 3
So,
Se, n+ calls ave equlred and
Prin Values
no o calls
The The wbsnk ene 's depends on
(n) Tn-2
TestCn-
1
(n-1)4-
2
TO
X
Tn) (n9
0/
Sobsf ulion relle!-E oid fest (:nt n
T
1.
) . a-)+|>0
we
n-)?
Know
n)-tn-)+T)-1n-I)+|
1n-)- 1-i+
Subs:ule 1n-n e O
10)1- n-
1n-?
1-1n-i+t>9
Subslihule
we know
1(n7/n-)+
1n-2 in eq 1n-Tn-)+1
1)-in-+2
1)-Tn-3)+3>
Continue Yo k nes
1-1-)+k/->0
Asure that n-K) o
Tn)- To) +n
Tn)1+ Soa)>O)
Mastenheoer
where
n: Size o Inpo
a o ot Subph»blens in ecugio)
Size o Sobphobler
recursive Call.
Cos f te woak done ouse the
C eSa
CaSe-1 K hen 1)-e)
CaSe-2
If a -
f P - then T/)- o lof:'
then
re-) then T-e
CaSe-3
K
Tt acb"
34
1hS ConeS UndeP CaSe-3B
Pn.
1-9T/4)+
Hasfer's Theyr
-aA)+1)
)
a : 4 , b 2 , k:2, Po
Conpahe a tb
a
This S CaSe2
n3 1 1/4)+
1-a1)+f)
a : b : 2 , 2 , P:o
ConPabe a4K
14
ac
This S Cale 2
ne Cornplexiky O(n)
19naVe lling Salesrnan ob ler -
8unch4 Boond
3
o 20 30
I6 2
33
19 18 o 3
s16 14
oo lo 20 o
13 2
3 Mid-
31
3
s12 3 12
olo 17 O
12
3
3
93/ e-25
)
Cust onede ]
makeok colann , ) ) a. a
A
2
o+ 29 +O
od O 22
12
12 do
Cost of 3node to
S
toake ew ot C31) aß a oo
Colunn
c(13)4%+b 12 2
17+2S + 11
53
3
12
2
2
3
Cos o node t
1ake row & 4h colamn &
(1,1) s a c
e)x" 12 e 6
O+2540 33 2
2S
12
cs co 2
+25+5
S
31 12
C2S
C S 10 9 O
C: 3 O
C 2S
12
(
12
eSo
c
c
3 25+o
28
I
h
Cost of 7hede 7
Make 'ow 3 colunn and
cic+" 12
2 2
12+ 2S + 13
So
c4s+c[+ 12
t 2 525+1
36
C2S
e
c:3S
e-S3
CS
3
e-
c - 5 2
C
Cos o"nodeto
o
es
28 + )3 C
S2
.
Cos lo node g to lo
nd
hake So colann 4si aRca
ce.3+c]"
O 28 +O
2 23
TouiSI 2 >S 3|
lo+6+ 24+3
23
Dynah'c Poqa1102
thsbreaks he poblens
fhe
1s a technique iuture
and' Saves he Resul fo
nto Sub-poblens
do not
to Coftpule the
need to
poses So that We
So
Haip. USe ot dyaiC phoqt1M
phoqtihi
e solt again. The
Phabns.
istoe ophitizatin
thak if s aa tec hniq. T
Prografi1ing. Says
Dyoatic nst beaking
poblern b
o Bolvin a Conplex
subpsobleris Soluna
SiMple
nto
nto aa ,
Collection
es out
ies allhe fpss:blthes ill a salisaSafistao
Soluion is no found
+19 23
O lo 2
13+48- 16- . o
lo415-(2). 3),
(y)13 13 12
L48-26
-4-3 10 5s 44-1 13S
3) 3()
28
s9mo)+1
(13
3
Min
.21
+6
(
+3
13+
18
Backnackia
1 is a Vedp inpotant s:llSekto sol
ne CusVe Solutiong Backlracking
nane Syagests
ifsel} SqesEs
d99went twayS
hre e Thvee
stwih rlaxinur Puit
obJects f wehto Rertainin iwenpt
3 S S-9 lo
2 3 lo3 = 7
3 4-3-
S 4-3 3
3 3-3-
Total poiB 472
oth ninmun Weight
oe cs i weqht Rertaininwejght
15-1 1
S
13-2
2 3 8
3
8-3 S
5x1:3
Hax, nuM
with
14-1 3
13-3lo
3 S-32
2
Fro three
above methods is he
is the best
3 , we Should llo he e h to
KnapSack phoble twith
Salue the roctian
the
Grmerd Meiho
D4nanic Proq1a1nin
n
Hann9, Max ,,, )+9,,(0-)+.
Hax )+,(6-)+6
Hay ,+%(4-3J+ 2
nax +1,+2
3,0) May 4, D
+32+1 2+1)+
Hax 3,+3,(-+R
- nax S,+ +5
9naph a Ve9a
The qrph has Tuo pesf Taveal.algsn:Bhns
Rreadlh Fist Sadrh BFS Depth st SevehDFS
foni to n do
ton eách Ventex w adJacent tron
U do
fo - I to n d
VIS:hed].)4hen DFS
Stack
QUeue Resal
o3,16,5, 2
eato3,2,5,,4
3
Single orCe
0-
Shan tect
o to Al Pasps
Oto = 12
o to 3 19
o to y 2/
o ko 1
o to 9
&
o to 7 3
o fo 8 7
1O 3 oo
8O 2 o
3 o
S
6
r
8
o
C e
a 1
O
O oo
-
J ected qnap
Reachab:l:ly Matnix
ransVe clous
23
3I
MiAiHr SPanning bee knuskalS
ohden o} weights
S9t he edjes n ascending
iht.
2 Pick he ed ge w:h he lexst we Checkf
D 16 O
(Y S
19 3
12
1o+25+22 +12+1,+19
neTe aSne wo Me thods
Ksuskol alaositbn 9iMS wge'sit hry
-0 l 6 0
2S
.
s
O, o +25+2z +/2+/6t!y
lo425+22z+l2+ +l4
-
- 11
(
CTT
opolgicd Son
o tices 9Such Ha
aa
ineasodnin
Sh ->
Find nConin edes
haVin 2cro
incon
,n9.
Find noo
3Ebirnanabe 3ero
'2,3S
1, 21 S3
Nettwon Ylow
He
Soe
slep
In: to
-2-5-7 S
akh low
1-3- 7
fafh flow
-24S-7 2
ath flow
0-3-4-9-
Onit-
1Pmclobepsbleri
A prodlert thl Is S/labe by aPolynotal-hre
aclasle phsberi. his poblems
can
Intaclable poblet1
tirie
A Probe that Cant de solved b a folyborial-
algonithrt s nown os Tniebbe Proble
Exorple
List of oll patiukations on nutbess
Corplexsty closses
whoSe Solafions ae
The exist Poblets
Sotte
ae divded
nto clasces kmuon
not yet lound, thal problers can be Sol ved
n heor
SolVed in
hot
heary buot
This phoblens
Coplevjs clasSes,
Cotple no in pnaches
Types ot Corplexsy
chases p Coltpk
N
) f class
DNp classs
-Aph
3) MP Conplee
4 Np Hahd
P-chss 1te.
in P-class slands fon lq non al
The Yes
ollecfion deciSion rblens Jwith
1s he de len mio Istie
delesrtin tstie
No answos
Can be Slued by a
in polyno1ie ine
Machine
S esy to nd
1he Sluion to P probles thot ae
clasS co Conpulabenal p blens
P S a
p clags Sands fo
The NP tn
ol dec:Son pao
collechion Polyno Hial ine
> T S the
> T non
derebninisthc
nachirein
Halinq Probler
Np-onplete closs
Isoth Np and
and
A probler1 is Np-Cormplele +
Np-hand
phoblerns ahe hehad poblers nn NWe
NP
Mp-Conplebe
EVenlex Cove
knapknapSack,
Ck's heoert
in P Can be neducedn PolynoMial
T Any Poblett
luring Machi0e fo the Rle
Boo lea)
ie
tine by a
by Q de tepttinStic
ConSists o s e p
Non-
Non-
oi a polynortial tirne
The execution
GnVent
Hachine to a bonch ot
Delebrti nstic eninq Sormola &as i c
&s}ic i
thad
Yopred fonHul uch
ored
The Hachine atept ppot. Topmula s polyno rtial
m}ks o
ole
aShou he SuM
0 the SiRe opoble t
NP phoblera to L
Can poliyneMjally 9educe any
Np-Haed(-
Np
Corplete-LENp inlynonial tine
forL thls
uns
So
Dete HinShc and Non-dele9t1iOS tic Alqomthr13
A Else
i-choile(1:0)
del
S(A then Fallabe C;
Sulle SsC
( O
De leninis/ic Alantlh
Non-deleinstic Agonilhr
For
For a Pambicalan input the Fon a ftalsh np th
Compubes 4vill 93Ve alsays the Ctpuder wil iue dS Serent
Safte ootpPt orputs an eent everukin
Can alue the poben ant 3olue the
in
n polynaM) al ie obleh pyntal lirn
Ney step o
Ney F Cxeculon* Next sp o
Cxeation
Co be deer1intd Cont bt dekesmied
• G lLon~u H Conru }ir1J ""
• ;f 1J IS a. n o!}leo... oY' U'HfJeJJ Scie flce H,J us.e,s
the f"ioci ples ot [u qnhJt1 fheoJ?J-
?f1l f)(f\qi"-~ tht: behqVioJ-1 c,i ene"J)' al\J Ha.te'J?l ,J on
the o.loH ;e, qnJ .subJ-oHic levels
)'. qlllqrJuM (ot1ruh1 uses .suL,.toHIC l""J,cJs _) Such
~
19 a.S elec~~ns Eh pho h,ns. Quqr,{4t1 b·, 6 oJ/ t.v /heS?L
0
stJes ol f~ un U
~
· Mc.. J /;Fie:... 3Ane- J; ne Hto.£t,J-,rJ
6
Wh; le. +o AJ __s (',, r1 FJ,,Jo_s Us. e . e. i ] 4J- bds } J?q"tc;,"j-
a.n.j a.nJ ~ ~
9}talt.o. n
n«11 \,u,
Co11 j JtJi
l,Jween
Cc, n
o
Lt se. e>J ~ I- -1~ bite:
'2-55,_,
l--o_ 81e~;
q_
£()ta. r]J le 11et1 _t ~ A phJs ic.J. ..97e \.,J;ol)S h; f 1,tfween two &,
r1oJ7e <JP bif--s \n w~;ch one 11.1 bi J- ge en..S fo knaw I w'J.,,J
ho.rren~ lo a.110 ~he,-, ...J even .(..Jhet1 f-1,~ oJie. a. &i.,:_f d~k
Qll.all l... ri 1,,Mr,l~ : A \e!e ~ -'1 f,,J;o(\ rheno mnon whtJ1e.b_J
0
I • •
E__ -- .
~ '1\J r ()
u :c 1,j t/~,_, \ 5J
~ (l \ ~ =- S S1JS'l__,S,:/l
~ 1 :c 7.,, '-IJ IJ ~ Ca s t- "j L, :J
S.i, = ), iA} eo.sf = lo
S ~ '- l '.J 1J :J '.?.__, Co S ~ "'-2,
Fi()J -fht M', f)\Ht.tf1 't' 11,x;n4n Cos~ sJ- CoVif)
Co~t ~ i;+fo +3
=- )B
1-- ,f)
C C'I-')~ '
CL'I) = LS
•
• • C [zj ~-:,
~l
r
X=dx .,_ c[r]'
\ ~-c\
:: @ t =f 'Z-
3
'j-:o CX/ = c ['t]
ls- C)
=_LS~~ 7,5
(__.,,
~r~eJ