0% found this document useful (0 votes)
31 views22 pages

Unit - 1 DAA

1. The document discusses complexity classes such as P, NP, NP-hard, and NP-complete. 2. It explains that problems in P can be solved in polynomial time by a deterministic algorithm, while NP problems may not be deterministic but can be solved in polynomial time by a non-deterministic algorithm. 3. NP-hard problems are as hard as any problem in NP, and NP-complete problems are NP-hard and are also in NP, meaning they are the hardest problems in NP.

Uploaded by

kumarasu356
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)
31 views22 pages

Unit - 1 DAA

1. The document discusses complexity classes such as P, NP, NP-hard, and NP-complete. 2. It explains that problems in P can be solved in polynomial time by a deterministic algorithm, while NP problems may not be deterministic but can be solved in polynomial time by a non-deterministic algorithm. 3. NP-hard problems are as hard as any problem in NP, and NP-complete problems are NP-hard and are also in NP, meaning they are the hardest problems in NP.

Uploaded by

kumarasu356
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/ 22

Unit-o1

sheet

enbeas.
esoyy prce agond sol equanhtatie laulitahver
athat isgdsal
A geud saltion is economcal in dhe use a
Agaud sal posseICI
dhe hllo. qualihe CopabLhei
Sinptyet poutirld gençal sal"
carily indeatd athes, eariy mocbed
’Corek Iulh, eLon uanicalin the se conpteo tme,
Computer stox age &peritheralt
’Dacamcaded, sawth kers oepandences on au paihtax
hiw or iepantabiity
Sub-pcedures, n pateh-wtnk sal"
’Quahtitate measuer asc woluable as hy
proide a way cf lirecty ptoliching ealuahng

Dore elhient clgoseult n


Computationt, hich oesult in saving ompste
erOUYCe uiage which in tun save time f

e Ooe ofhe mort ditheult seguitnot to satir


s to sbow that a wosks correcty
oltput with enetted behaviour & erld
Oin he Coalete ranse of ata ie uied
to haadle
Algo should be testedie dielin idee tertng
lons th prete instead od enhaushie testing.
E. ateh bon -do lish boytiutet
Alyo. shustd be debnite, easyAtab/eter mincde
dter a bote numbex af pevatiaor
Ago is to te odescnbedin termr ot a Jangage
that the cnput can undasda nd iepram
agnplati tledatonr.
This dpic Comer hm mathamather bcz dsshos
belongr do medhCrmtic.

ine compleri ty conyplen pmblbmt,thot g


Ootatians
Cleutak time tomplenity wsing oth n.

Def"
The hai fol Oglal) ifk positive contont
suth dhat fn)<c*gln) tt n,ne,c)02D
ntiat

F(n) 2nt3
he can wgite hee

2nt3 5n if n>i
fon)

fon) =O(6)
Anethe _mcthud to go gagkt side slh is

Loight nide silo ih n


2nt3 5n
Anodhesmethod
2nt3K2n+3n Also possible oo bue

fin)=O ) alc parsibk


tusfln) belanys d to clarl,gitn abetuie. all fu'
ih ane tatn hann' n ab0re clas Cam
satis ty Jhii tue. called uppes bamel.
laponod cuach ahe o(n)
incar Oln)
hg-ihie ollg)
Conrtant 0 )

So Ca s om be

1occ bamd
<a23..n
bond per boua d

Say

uhen yeu wnte big. oh, then byy. h wmte chtert f


So hese n)=o?n) is clorat ha all highe ha

Z Omea ()qtation hawer baund Bshnse

n)= 2n 43
2n+3 < we cam wite anthin hoe
which satuy he (onelihon.
2nt31n

obaAre can wate vale dhese


Cst smaller han ' n h t closec vale is 'n' fhat

3) Thela (0)noh aiani A beund NdHiNEp


the h Pn)=eg))

fln2n43
1n2nt3 5* n
)Lincor teasih

So hme ta ken is
not care time is ne

all possble casctne

Agthne 1+2+3 + t n é lanpamn


elemt
nt)
2

e Cases aoe nt eladed to ndatiins


Nodation arc onelated to funthonsqcore
juet dyec d analyi dencn olgo.
B()=fe(onidaat wCn)n A 0) ntr
B(n)Ol) w(n)=O) Aca)A
w(v)(n)
Bln) 1) w(n)eln)
Small elerntnd t) lefd
big elenenl to njhd
30)

Kest case tim e: Bn)=1

amlt ase iore wn)Egls logn


Arother CaLjwe cam daw asme binany search
hee ie deftqueued hiay seandh hee
sohene
Best ca te time Bn)1
buet
oct age timei wo)=n e
hegnt n height af he
win w(m)= logn
Amahzed Poalnis' ot od atrge
Amerhzdol amayir
Warst Cost zathez ha inoiridued pezahen urt!
Cact
Arooped

|0 +20tr+ 30 1

need entonsm ot a n a y , e clvbk site ot

23<|

Hen cost

-6ch t i e it
0 nitt t atceotI
Anethe
1 Arr ay

7
coS) cOJ

hletceyt
1

can say sie ofoy

3*(2N+2-1)= 3(4N- 1)
- 1N (onsolilat
2 2
Alyelhm
p[913)2S6la|F)2l
mid (Uth)l2
(3,S2.3)
S8 herst (wod, h)
(30)
erge U, mid h)

dog . lcnehlnlr elenont)


3logBbi 3 kel

ChËechve
ony ho shuw elahon bet" orpenanhalpstlemt
ieif one enpancntial prub. sareothen e
say ather fyplfnb can be Salved ig
Same wey
?)I yauane mabl to wmde dots nioitbe otea.
aly f dhenid cpeloiaf tine erdekt
P Hord Nlongkde

on aAentaA time
poneniat Tine
i> Lincax Scas ch o )
22 imay Seavch oleg)) 2) hading Salemo
) nsebon sot lon)) 3) &roph Colauing 2h
42 Meje sot Cookm ) 1) snDo -Ku
)6inay och (otlgn) s2 heduling

Thispnbey Jakc a palnonmiaA amtnd ad Jinc


to solre e. 0(0), O0)0(n°) et.
Thse arEpoblemy ane ca, o salve ie. hae

-> 4 uer determinshc algo.ie all stepr at dleartd.


NL dasr (Aon deteiniscesnonmial tine):
’ Non:cetraminishe alyo hich an be saltd in Polyhoe.
Apbe) whith can tre not be sah dd inalynoia
tine but can Be er licd in alynemelime.
Sdo-ku

19 take Ol2")hne
JL avd to check sdd

id ill dake polynaialtime


dedo sahe it takes my ¬
time bt totiyt take
palynomial time,

Prole into plynrid tine using nop-deterhide


NP
fsadable n Tatla blepok
|+Rsble
HprbemI comes under Pan ' called
tractable problm
Shoblenf Cones umde p. class' alle d
Ltacable pblem.
28derminshc Alze.
3 Thee are encal dlyoythmy t hich caa
be reksed in ectipeeihe mo wherd ue
Kadw dhat hw each eeny sttp wekJ.
Ej searchiny algo ike Iincar, pamy
Nan-detrmipishc Aloi
Ey Algo Nsearch CA,n key)
W=choice )eAhisstye not cleare
otr) c nondetem
if CAci]etlcy)
Quetess
pnnt (o) 0)

failue(), 3 <

-> Here we don't kaew how chaice c wte, bd


dhis adyo will get enelute inO(1)t
we conerd Jas alge. in palyneial time
Thats why it ir non- dlettninirhe dlgo
lbe aldd ia palynetial ties
shet 2
PIMPRICHINCHWAD EDUCATION TRUST'S
PIMPRI CHINCHWAD COLLEGEOF ENGINEERING
SECTOR NO.26, PRADHIKARAN, NIGDI, PUNE- 411 044
ANSWER BOOK 46452 12

Name of the Student

Course & Year Roll No.

Division. Date.

Subject No. of Supplement

5 6 7 8 10
Question No. 2 3

Marks

NpHasd
Reducban Crppr.
Redachss i ueed to show aeloaior bedi satishchliayt

pobom B ifthere a way to sahe A by


detniaisbe alo2. that sale ß iapeyntmtal
tim e.

I4 meass if pob. Aget sahd by any doter Anhi


then Bprob alro ged sold by Jhat same
detr iaithc alyo in p time

elatonbet? enpp pb
nced some base problen.
sa bese we lake sahitiabliy obles'as bauc
CEh l a icalled
it calleaos Bu sihenal aleuler faxaala.
CNE Satihablity p.in a bebley tetishabtbypol,
where e Beolean drnla ispecihed in cNE.
NE =(oyVi, Vo)A(,vagvi,)
clause
Sothe satishabitiy prob i fr ahitk

e total Ppoibiditie
take,ie. tztalfualie s
23-p for niableu
9h 1

s0CNE satifhabiliy belags do


enpo tine eblen
Z4 ue daae state space dee_them

saowT vanabler r ,
Same state saCe eecan

wls, 4,33
Sane as aboe.
St,Jhe way ur than cdetion bd satishabË he,
sotithabi l,

Paloma hiae

Satirhiobility d o1kmapratk Ep
nstane
t mean,i u e intdan ce4 od sahibobilty

Satiikably
NPHard

By tansi he propet

*So when any enpo pbb get sahed b poly. Bime


then itrcled NeHard prohlens beaenpas psd.
i also called nNeHble

NPMad Def"
A probk is NP Hard i£ erey plkn
in NP can be pa lynumicaly educe to id.
Har d

Rediceyno
ime.

Eg Getiizabier poblenm sharddpath


NP-CoPled Comlete it t is
Ppaben is NP
NPit i in NeHard.
ce
ifNom sale B wsiny
oledmminihe,Hen jt
A e B NP-Cnplete
uill betame

mkte

Had

E9. De cisian pobe (yerlolc)


hen the fHavd poblan get Cagplet zsod
non eleterminishcolgo,then itr aNe
Conyplete pebler7. inpayhime.

any problens 1 is
elatdho sotisbabiliy,then prob. is NP-Hend
14 weo wnte non-oletmniuhe lgon
poly ime, dhen prok it Ne-Conylete.
S a
Ci fu in derm cquadin o inequdlity Jhad describer
of/od ids wdlcon Srnaler input
Reurnce Relotian: e-
H euoence
equatioM that dehnstlotion tor a sequene is
terms. the restnd tem b,
user prtau
lurire Calr.

Lt uses T) to shw
dime daken
) Binagy
byninpuh.
en
Seoo th
aoray hvul bein

Key=x
Bs (aj,)
mid(ij))2
LE ==Camid) )ikey
OCoie (onstaut 30,40
else
if Calmid)) 1t our eg" i T() hen
Bs (a,i, mid i, n)
else
Bsla,midt&, j Cistauthe
tnine d

- Node Consdant
Te)
ahne me Can wnde ar a C'ar1.
2) Tecs f n3
To) Void est (oind n) lere 3he Test (3)
i (n>o) fpsinhiny value Rit
luhich dake foi!
Tet (2)
7(h-1) Test (n-1) Jie.3 Tect
Testo)
X

de. (nt 1) fn)0(n)


Ke unoe kel" soing mn elho dr alo butshw.
ph'rable do eul
1) substituio madhod but dardo
Nod aeicahle for all algu.
2) maste dhesYem!
3) Recuorhn ee.
t Maste Theven
To)=oT 4)4 fln) shatd be jn dhi fom
whene

Solutiom,
To)
ucn) deponlr on hn)
ha)fu)

Hese tlahian bot ) pucn)i

Case O(n)
0(1)

Cose 3

Eg ) T ) = (n1) +1
Sot Hene

by macter hee fm. sabshtudmedhudthàr can


Cbesoe d
2) Tn)= 8T/y)n
a-f,b:2fn)= n

=n°Cun)7 hl
fnn2
n
Case2.
pel"dable beth hn) am), caa

n i c Ol4)

3)

Sol"
TOn) nu(n7

(ale

Oalgn) time brplety


4) Binay iar th rtcupdnle otl
Hin)=79)+1
b 2 Fln) I
nttutn) Uny to)

hen)
n no we canunt

T(u) uln) Case 3 , 0

-
(ondie

Aoliviedes phen ind amay atn) nto lze,

T(w)

20 20 T(n% ) + T(n/) +32 urnt


to

323

To)= Tiy )+ TC4)A 32


7)274)+n
An
2nt3n td<9y

|2*4+6e+4 <7*4

Here -4,n)=nfr
So lond and
Vale doesnt att.

so her e
Jen)-o(nforc:9,n,721

R so
fu)

Ansi

at
both sides ad n )

So no vale hee thatig biy ch


valne hedalO).
4) Ln): lg n!
Ans

So hene alea_mo eait vale toxO .so we


notgoty ong. valeie
e_ fofactoialAmchen
5)fn)=2n°+ dnt5Find uc bned.
Any :

E11n3 for al no d

Leln)2nhnt 5

11 9 3
2 29 24 32
3. 54
71 81
129 192 2Sb )
2s 341 500
Fom dable, e
JE Cz3, no3 hen fn)kcxgen)e
2344nt5k3n°t'0(n)i hue
So,thet can be such mmul hiolepair ot (Cne
fo) 0gln) =o (n) toy C= 3, noz3
fn) =0yln) = o(n) for C=4, no2 2 2seon:
h-om all dhesC, we can Say that censtant ccan
c
be Changed but (glr)) shod be same

You might also like