Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

University of Massachusetts, Boston PHYSIC 211: CS 624 Lecture 8: Dynamic Programming 2026

Rating
-
Sold
-
Pages
14
Uploaded on
30-03-2026
Written in
2025/2026

University of Massachusetts, Boston PHYSIC 211: CS 624 Lecture 8: Dynamic Programming 2026

Content preview

CS 624
Lecture 8: Dynamic Programming



We’re now going to investigate a general method of attacking a certain class of problems. The
method is called dynamic programming. It doesn’t work on every problem, and it’s not needed on
many problems. (For instance, we have very good methods of sorting, and we don’t need to use the
technique of dynamic programming to deal with this problem.) But where dynamic programming
is appropriate, it can often give extremely good results.
We’ll start out by talking about a particular problem. We’ll show how it can be solved using dynamic
programming. Then we’ll summarize the technique, and see how it can be applied to a couple of
other problems.


1 Shortest paths in weighted DAGs
I have to start out with a word of caution. There are many variations of this problem, and there
are many different algorithms that have been designed for these variations. So we need to be very
particular about exactly what the problem is, and exactly how we are going to approach it.
And I should say from the beginning that even though you may find another algorithm for this
particular problem, the one I am going to present here is essential for you to understand; and this
is for two reasons:

1. It is as efficient as any other algorithm you will find.

2. It is key to understanding dynamic programming in general, and in particular the other two
problems we will consider afterwards.

So here is the problem:

1. We have a DAG G.

2. Each edge e of G has associated with it a weight w(e). In our problem, it will always be true
that for each edge e, w(e) > 0. (There are other variations of the problem where this is not
true. We are not concerned with those cases.)

3. If n1 → n2 → · · · → np is a path in G (where of course each edge ni → nj is a directed edge
from ni to nj ), we define the cost of that path to be the sum of the weights of the edges on
that path.


1

, 2 1 SHORTEST PATHS IN WEIGHTED DAGS


4. Each node of G has a name. One of the nodes of GR is named start and another node is
named end.

5. There is at least one path from start to end.

6. The problem is to find the path of least cost from start to end.

Figure 1 shows a very simple example of a DAG like this.




n13 n5

15 12
16

start n10

20 14 16 22 35
21

n12 n11 n8 10 n2

3 5 11
17
8 12

n1 n6 28 n4

15 20 14


7 n9
6 18

11 20

n3 end


19
21
n7


Figure 1: A simple weighted DAG with distinguished start and end nodes


You can think of this kind of problem as a simplified version of what Google maps or the GPS
in a car does when you want to find the shortest path from where you are to some destination.

Document information

Uploaded on
March 30, 2026
Number of pages
14
Written in
2025/2026
Type
Class notes
Professor(s)
Prof
Contains
All classes

Subjects

$18.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
REIGNDOCS
3.0
(1)

Get to know the seller

Seller avatar
REIGNDOCS Stanford University
View profile
Follow You need to be logged in order to follow users or courses
Sold
2
Member since
1 year
Number of followers
0
Documents
306
Last sold
1 month ago

Welcome to REIGNDOCS, your trusted source for exam-focused academic resources.

3.0

1 reviews

5
0
4
0
3
1
2
0
1
0

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions