0% found this document useful (0 votes)
13 views32 pages

Dynamic Programming (DP) 08 - Class Notes

The document covers Dynamic Programming (DP) with a focus on the Traveling Salesman Problem (TSP). It discusses the optimization techniques for TSP, including the use of DP algorithms to minimize tour costs. Additionally, it highlights the time and space complexities associated with solving TSP using these methods.
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)
13 views32 pages

Dynamic Programming (DP) 08 - Class Notes

The document covers Dynamic Programming (DP) with a focus on the Traveling Salesman Problem (TSP). It discusses the optimization techniques for TSP, including the use of DP algorithms to minimize tour costs. Additionally, it highlights the time and space complexities associated with solving TSP using these methods.
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/ 32

CS & IT 20 25

ENGINEERING
Algorithms

Dynamic Programming(DP)

Lecture No.- 08 By- Aditya sir


Recap of Previous Lecture

MultistagGrah
Topic

Topic
Topics to be Covered

Topic Salesman Problem


Travelling
Topic
TSP
PUGS

3
111 A qpqrr n
Length of LCS
B paprarp y no LCS
of
I
ntloy

5
LIS apart pqprqrp

LLS qpq pqprqrp


vs apart paprqr

It
LCS ape
__
Paprarp Les
fear papror so

LLS aera P
endt prq
end
qpqr Napa
apa apq par
e
x

5
a ten us 4
111
no LLS 3 ax
4 of
2 arpar

3 purr
24
toy 9 10 3
4 apr
4 30

31

5
Topic : Dynamic Programming (DP)

stageaph
culti
stlegraph
multi

min C cost ith k


cost i j j k

KE Viti

Cj KJEE
cost 1 1
j CCJ t
e stages
that k which
D i j k
destination minimize cost i j
5
8 Saleman Problem TSP
Travelling cities untices
the home
TSP should strat from
The of
city Vo and visit rematches
to the
and comeback
yone the
such that
home city Vo

the tour is minimum


cost of

5
vertex Vo
home city Starting

Vo
Tour
V
Odie

Problem
TSP optimization

minimize the
Objection function tozcost.­ee

5
E c

yardynthodi
I
1 2 3 4
costymatic atom
19 20

31
5
The actual optimal minimum Tour cost is

1 2 y 3 1
10 100 9 6

20415 3 optimal solution

ImpHot
solve TSP by gardy we
get min
If we

39 172 3 4 which
tour lost as

5 is NOT optimal soln Here gueedy fails for


TSP
DP based solution

represent
the cost of the
Let g is
four of TSP vertex I'and visiting
from
all the vertices intheset'S exactly
at
once andTangthour
Vo source et
sont c

era
I
5
Vo l
k s k
1 min 4K
g 2,34 g
KEES
and
4K EE

original problem

g 1 s 1 Kurt subproblem

1 k 9 K S 1k
6
generalised form Imp

9 i min cli k g k s 13
KES

LI KEE

starting vertex
9 i 0 c i
To make sure
i Vo source V0
back to

minimizes earn
J i 5 value of k that

6
i.­es onginalproblem
SOWELLS
3,43J
k 2 1,2 9 2

9 1 min
2,3 1 3 1,3 9 3 2,43
K 4 CCI 4 9 4 2,3
Costadjmatic

is 1

5 Bottom up
5
151 0
01
i 2131
C
9 2,0 2 1 5

C
9 3,0 3,1 6

C
8
914,0 4,1

6
IS

33 2,3 9 3,0
912
3
3 2 33 9 6 15

912 943
2,4 9 4,0 10 8
11
562,54 2 4

9 3 2
c 3,2 9 2,0 13 5
11
313 23 2

g 3 43 3,4 9 4,0 12 8 20
6 513,943 4
914 23 c
4,2 9 2,0
2
8 5 13
3 4,4237

g 4 33 c 4 3 913,0
9 6
15
514,231 1

6
151 2
24,37 set

same
3
9 2 3,43 min k 2,3 9 3 43

14 2,4 9 4 33
mm

min k 3 9 20
Gompaer
gg
Subproblem
10
5 243,437 6
e

min 2
29
6
9 3 2,43 min k 2 3,2 9 2 a

k 4 C 2
3,4 g 4

min k 2 13 18
12 13
J 3,52 43 4

31
min 25
25

6
9 min 4,2 9 2,933
4 2,3
f 4,3 g 3 24

min k 2 8 15

k 3 9 18
2
J 4 2,33
23
min 10 2

k 3
27

231
6
i.­es onginalproblem
SOWELLS
3,43J
k 2 1,2 9 2

9 1 min
2,3 1 3 1,3 9 3 2,43
K 4 CCI 4 9 4 2,3
Costadjmatic

is 1

5 Bottom up
C 1,2 9 2 3,43
1,3 43 min
g 1
113 3 2,43
Ku Yu g 4 2,33

k 2 10 25
min
1 3 15 25
4 4 20 23

min
10 2 35
135J
4 3 40
6 1 4 43
How to determine the which
min cost
path for
we got
Tof

1 2 4
Tour reported
by
3T

TSP

Cost
31

6
top Down Renee v
Imp
91 3,43
4 2
4
4 114
1,2
9113
9 422,33
9 3 92,43
9 2 3,43
K
4 11 2
1
C 9,2 44,3 t
3

uz 9 4,13 g jus g É 91453 913,92

I t t
6 9130101 9 91200
DP based to solve
Held Karp Algo Algo
the Salesman Problem
Travelling
II
1 Time Complexity 0 2ⁿ n

n no
of
2 Space Complexity O 2nA In cities

those Problems for which there


11 TSP is one
of
6 is no polynomial TC as
of now
11 2ms when run
from
0.1 Dijkstras SSSP Algo
vortex a in the below graph computes
shortest distance to
the path

e
a only vertex a

1
1 f 9,4
74 f b only vertices 9 e

12 d g
c only vertices a b c d

Dj
6 he cut edges
never
cant guarantee.to thevertics
sots
a b c d e f g

0 0 0 0 0 a
a a

0
02
3 9 0
0 1 a
9,61
0 1 2 0 00 0
a b e 3 00

H W
0 1 3 2 0 00
a b e f 00

arbie f c
0 1 3 6 2 0 3
6
arb 3 0
e f c h 0 1 60 2 3 2

0 3 2
a b p f c h d 0 1 3 6 2

6
0492 gated 21
He
3

a 2

f e

How distinct MCSTS


many

6
01

THANK - YOU

Telegram Link for Aditya Jain sir:


https://t.me/AdityaSir_PW

You might also like