You are on page 1of 20

Ass ignmant.

g Date :

{A,B, CBD, A BÌ

B D A
o
A
B 2 2
2 2 2 2
BB 2 2 3 3
24-2 2 3
(A) 2 2 4
2 2 3

Ans: BDAB

Q.2 Sz
S

1 1
b 2 2 2 2 2 2
2 2 3 3
2 2 2 3 3
2, 2 2 2 3 3
24-2 t 2 3

1 2 2 3 34-3 3 4
2 2 3 3
44-4
ASHAPURA) Ans: dcba
Ropal ECO
Date

Q2 S2 o b
S

2. 2. 2 2 2 2.
2 3 3

2
2 2 22
2. 3
3 3
3
23
2 3 4
2
4
2

ans:
bedba

@.3
2 S

2 3
d 5
2 2
d3 3 4
2 | 2 3

Bact- Toeng
cC3]= 4 C[2,7]-6 not Stre
i=3i-di= 4-4 =3
(ASHAPURA) cl3] Sare
Ropal ECO
ECoRopal (ASHAPURA)
lo t(o,o) lot ma0
C-w) k(i-4, +I0 man
45 40
37 27 3 =
37
(a 22 22 22 22 12
lo to 1
2
2
30 |2
C6 1
3 2
e43}
l4,3 S= I=2
Sare not
|-2 3
Date:
Date:

tCe) = mar( to, 2tk (1,0)) = t22


k(2,3): man lo 12tkCL))= 22
k(2,4)= ma(to.l2t tCI,2)) : 22
kC2s): max (to,l2tCÈ, 3))= 22

A(3,2)= may (Q, 15+ K(2, o)) IS


EC3,3): nman 20. Ist ECe))) =2s
kC3,4): max (22, St k(?,2) ) It(S = 27
to,s) = (1 t kc2,3)) 22+ Is = 39
mar 9., (5t EC?,4) ) :

4,3) = nar ( 2S 3o t k(3,o )) 3o


tcu,4): Ho
kc4i) 30}F(3,2))
nar 3 3otkc3,3) ) 3o+ S= sS

Back Toach
kC3,6]= 34 not Sgne,

2.
EC4.: 4s Er3,5J 737 not S#rne.
C= S- 273

not Sq me
3
(ASHAPURA
Ropal ECO
Date:

2.
k C4,3J<Bo ACa, 3]= 25 notSame
C= 3-3o
3 kC3

Totel aoft = 30 +S t o
Date :

A1
A2 3SxI S
A

AG

2 3 S
$750 7845 -1 9375 -3||a5.3 S|2Sr3
2 2625 -
y3ts-37(25-42S00-3
{o S -3
S35.3

Se 1
m(2,3]
mC3.4]
m(4,s ]: Sklo 20

Step 2 nin mel3t mC)t P,P3 Po

m[24] min

ASHAPURA) 4375
Bopal ECO
Date:

mC3,5: min
mC3,43t msi s]+ Py Ps

m(4i6]: min
m4, SJr mCce]t P2 Pe P

-ol
2 3 S
3 3 3
2 2 4 3
3 3
4

(A1 A2 Ag Ay As

( Az
A3)Ay As

(AA3))_(ay As) Ac

(ASHAPURA)
Date:

ifem=s
c(w)
H| Iy
2 S
22 28

2 3

2 2 6 4
S (8 21

4 6 22 28 29
6 22 28 2 34 35

ltt(o,o ))=|
t(I,2) (o,E(e.J))=J
kCe, 2):
kC23)=
mat

t(3,S)=
t(34)=

k(3.6)= max

(ASHAPURA

30pal ECo
Eco Ropal ASHAPURA)
pdtt= Total
k(2,s) |§5)= E3,
Sqre hot
|-3
Sarl k(sI)=4o
Taciy i ack B
21
kC3,3))= f22 k(41)
lc3,3))
29 - (4,224 man
kc3/)):
29 (19,22t kcu)
22 )= D) Icc3, 22+
Date:

Explain Dijttaa'salgoaithr
Dykstaa alsoxithm
DjLstoa sed goeph toavessal ¢
patafnding algozithrm.
DËkshe Ued to find Shorest path beteen
tu nodes in a weiqhled goaph
Thisalaosith is efficient and wets taó
twell Aro finding the Shotest patth when als
negehe
Steps

). Jniialzakion in tiali2e the distonae of the


Stastrq node
all othor hode
nadeith Smallest isanoe
2), SQlect Hhe
3) Updale distano
Maxk node visiled
CoVere
Repeal

A)

[2

ASHAPURA
Ropal ECo
Date:

Sousce A
A
B D
) 12
AB (6
A,B,
ABED
(6) 19
DEb,C,
Minimun Spannirg tree '
A minjmumm Spagnng
Spannin toee of a weightcd onnec led
qsoph Ck is a
Spannng
Smallet weight of edges.
ousalS
In kauskal 's algooihm, the set 4 of edyes
incseosing cadeo of tteeia lengh

3 edge Connec le Carnponcnt

Le,3]
6
I23]

ASHAPURAotal weght 's =


3Ropal cco
Dg
Date:

(2
2
enge

Bzien's aloa1thm
In paim's algo the minmg Spanning tre
tn a natyal way sterol-ng fom gn asbitsa qaca
aot
in

Stastirg node =j
Cost edye Node

4 t3,< tl,3,)
el,6,4,3}
{s6}
3

HAPURA)
Ropal Eco
Date:

Poinciple oft Optimality


The paiaci ple of
optimal Sequence ofoptimalihy stak ttat nAn

Subsequonce muat alsodecisions


be oplima! "
Dynamic aogaamming
characleaize the stecuze of gn optinal Saluhon
pecuasively datne the Valee of gn optimel
Solaeion.
Corapule the Value of an Dptima saluton
in Gotlom- up fashlen.
Canstaect an Dptionel Solution fanm Cormpted
nfonalion.
:"if k
painciale at apicaaliy
shortest path foom
the to then the pat
i to the
to rmustalso be oetima

(ASHAPURA)
Ropal ECO
Date

Explain Back Tracting method wi th t of NQUEEN


problem AlSo wsite site algo oitth m

The classic poalem of placing quceai on


chessboad n Such aa wwa that nane of tom
thaeafen s any s the otthex
Pecall that e queen tareuteAs te Squares in the
Same the Same. olumn, 0d the same

cdiagpnals
Solutton using bact hacking i
Back Iaacking allous do betleo than this. As
Fiast dep, we aefosmulate the eight queen's problem
tyee seaschig pvblem we say that a
Vectos
paormisigg. fos osE ÇoIf none of teE queens placad
pasitian 4 VC]aUc2),(t VCK] ) thseatens
in
ang ot tte other

poceduae queoni E, cols, dag 4s, dagl3s

dag135=
then Lan 8-Pomising vec is a solutton
lwaite sof.
f Sol
etse Lexplo (ktt) romSg ertensions
b y - 1 to 8 do
beongs to col and -k does nst
if daes not
Roval eco
botorgs
ASHAPURA
Date :

then so|[ttIJe /
t solC... kt1] is K+) - paomising J
queens (kti

Soluton of Qqueen ponblen -

2
2
1

ND Slton
2.

ND
SoletiDn.
Kopal ECO
ASHAPURA)
Date:

oile easigent paoblem wAig banch and bound


metnd fo Solving the problem
let thene be N Josters and ANobs, Any
wostex
Can be assiqned to peafsm 0y any b, inunng
nUTIng So
cast that ay Vag depending the wost-ob
assignmeat. Jt is Tequisedto pesfusm allljobs by
ausigning
Qne ob
exact ly
each
Dne wkes t cachjob and enactly
ageat in Sch a ay tat the
btal lost of Sgament is minimized
2

2
B
m
S
D 6

P Solution using Bsanch t Bound


5 each woo teo we chooseJob witth mìnimum.
Cost fom list ot unas
ent om each ignedjobs(takeminimun
Fos eachjob, we choase. woskes with Dwedt
Cost iab faDm list of enassigned wxkext
Ctake minlmun enty from each column)

ASHAPURA Ropal CO
wite Enuth mossis - Pratt Stsing matching algaitor

knuthMoTÍS and Poalt poopased a lineas tine algo


fos the stoing matching paoblem.
kmp- mATCHER (T P)
ne length l7]
me leng thl I
- Compute -Pretix Fnction (e)
num ber ot chs matched
do hile

then e t

then pTnt Pottegn ra oCus ith Shift)-m

Compule- Prefs- Fenction CP)


lengthCe]

do while K>ó and PCkt 1J PCJ


do
it
then tekt 1

retus

ASHAPURA)
Ropal ECO
Date:

2 6
b b b
2 4

b b efloC a

2a
P2
a b a b Ca

Define.
folag
solvable in
The class P of hose pooblem tthat Qre
Consist
pDlnomial tine. That an be soued n trhe O(ok)

NP
Consiste of ho le paoblems thet qe veafiable!
Tne ctass ANP
in
paynomial tine

NP-hatd NPHdefined as
NP-hardeitten as
The class least as ha the
thot qe At
b7Dblems problen in p'
hasdest Bopal ECO

ASHAPURA)
Complete þsblem
s
to
iteducible
pynomial-
tire A
the then
NPothex all cnd NP Called pathem
is H
Conplete NPA
Date:
Date :

Lwsite Enuth Morsis- Pratt ststng matching algpaith

knuthmossÍS and Poatt pooposed aa lineas time algo


the stsíng matching paoblem.

Lmp-mATCHER (TP)
n lengthl]
length C1
e ompufe - Prefix- Fnction [e)
num ber ot ch mtched

do hile and Cti] TCi1


le

then pont Potten a ocCus ith Shift -m

Compute- Paet- Fncion CP

whileK26 and

if PCEtz] = Þl3]
thhen Ekt1

retus
ROval ECO
AAPIRA)

You might also like