Professional Documents
Culture Documents
Algorithm Design Techiques I
Algorithm Design Techiques I
a solution to subproblem 1
a solution to subproblem 2
1. n = 4, (p1,p2,P3,p4) = (100,10,15,27),
(d1, d2,d3, d4) = (2,1, 2,1)
Clearly, all programs can be stored on the tape if and only if the sum of the
lengths of the programs is at most I.
We assume that whenever a program is to be retrieved from this tape, the tape is
initially positioned at the front.
d(I) =
n j
L
j1 k 1
ik
Example
n = 3 and (l1, l2, l3)= (5,10,3)
The files x1,x2, and x3 are three sorted files of length30, 20,and
Find an optimal binary merge pattern for five files whose lengths
In the problem we consider, we are given a directed graph G = (V, E), a weighting
function cost for the edges of G, and a source vertex .
The problem is to determine the shortest paths from to all the remaining vertices of
G.
The shortest path between and some Other node is an ordering among a subset
of the edges
Example
Source is 1 1 2 3 4 5 6
1 0 50 45 10
∞ ∞
2
∞ 0 10 15
∞ ∞
3
∞ ∞ 0 ∞ 30 ∞
4 20
∞ ∞ 0 15 ∞
5 ∞ 20 35 ∞ 0 ∞
6
∞ ∞ ∞ ∞ 3 0
Algorithm
Analysis
First for loop executes for n vertices times
Source vertex is 1