






























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This course object is to design and analysis of modern algorithms, different variants, accuracy, efficiency, comparing efficiencies, advance designing techniques. In this course algorithm will be analyse using real world examples. This lecture includes: Knapsack, Problem, Algorithm, Dynamic, Programming, Optimal, Weight, Triangulation, Generalization, Variations, Dynamic
Typology: Slides
1 / 38
This page cannot be seen from the preview
Don't miss anything!































-^
V[i, j] = max(V[i-1, j], v
]);i
-^
i = 4
V[4, 10] = max(70, 50 + 40) = 90;
Keep(4, 10) = 1
-^
i = 3
V[3, 10 - 3] = V[3, 7] = max(40, 30) = 40 Keep(3, 7) = 0
-^
i = 2
V[2, 7] = max(10, 40) = 40
Keep(2, 7) = 1
-^
i = 1
V[1, 7-4] = V[1, 3] = 0
Keep(1, 3) = 0
Constructing Optimal Solution
KnapSack (v, w, n, W)for (i = 1 to n), V[i, 0] = 0;for (j = 0 to W), V[0, j] = 0;for (i = 1 to n)
for (j = 1 to W)
if (w(i)
j) V[i, j] = max(V[i-1, j], v
]);i
else
V[i, j] = V[i-1, j];
Return V[n, W]Time Complexity O(n.W)
Algorithm : Dynamic Programming
KnapSack(v, w, n, W)for (w = 0 to W), V[0, w] = 0; for (i = 1 to n), V[i, 0] = 0;for (i = 1 to n)
for (w = 1 to W)
if ((w(i)
w) and (v
] > V[i-1,w]))i
V[i, w] = (v
];i
keep[i, w] = 1;
else
V[i, w] = V[i-1,w];keep[i, w] = 0;
K = W;
for (i = n down to 1)
if keep[i, K] = = 1
output iK = K – w
i
Return V[n, W]
Complete: Dynamic Programming Algorithm
Common to all versions are a set of n items, with eachitem 1
≤
j^
≤^
n having an associated profit p
and weight wj^
.j
-^
The objective is to pick some of the items, with maximaltotal profit, obeying that maximum total weight limit W.
-^
Generally, coefficients are scaled to become integers, andthey are almost always assumed to be positive.
-^
The knapsack problem in its most basic form:maximize
subject to
xi
{0, 1},
1
≤
i^
≤
n
n i
i xi p 1
n i
i i^
1
i^
{0, 1})
If each item can be chosen multiple times, we get thebounded knapsack problem.
-^
Suppose, weight of each item is at least 1 unit, thenwe can never choose an item more than W times.
-^
This is another variation in the basic form
-^
Now the problem will becomemaximize
subject to
x^ i
{0, 1,.. ., W},
1
≤
i^
≤
n
n i
i xi p 1
n i
i i^
1
If the items are subdivided into k classes denoted N
i
-^
And exactly one item must be taken from each class
-^
We get the multiple choice knapsack problem
-^
In this case our optimized mathematical model ismaximize
subject to
1
≤
i^
≤^
k
xij
{0, 1},
1
≤
i^
≤^
k, j
N
i
k i
ij ij
N j
i
1
1
x
ere wh
Ni j
ij
1
^
W
x w
n i
ij ij
N j^
i
If in the multiple knapsack problem, the weightsare not the same in every container
-^
We are allowed to choose each item multipletimes, we get multiple constrained knapsackproblemmaximize
subject to
n j
j xj p 1
m i 1
1
i
n j
j ij^
W
x w
Z
x
j
j^
0,
x
Optimal triangulation problem is very similar tomatrix chain multiplication
-^
It is an excellent approach to make one to onecorresponding between two problems and
-^
Then solving one problem based on the approachalready used in the solution of the other problem
-^
This is what we are going to do in solving anoptimal solution of the triangulation problem whichis very popular in computational geometry
-^
Applications of this problem can be observed inmany other areas where division of structures isrequired before performing computation over it.
Similarity: Optimal Polygon Triangulation, other Problem
Polygon
A set of finite piecewise-linear, closed curve in a plane iscalled a polygon Sides
The pieces of the polygon are called its sides Vertex
A point joining two consecutive sides is called a vertex Interior
The set of points in the plane enclosed by a simplepolygon forms interior of the polygon Boundary
The set of point on the polygon forms its boundary Exterior
The set of points surrounding the polygon form its exterior
Basic Concepts
Simple Polygon Convex Polygons
Simple Polygon
Polygon
Polygons
-^
For a convex polygon, it is assumed that its vertices arelabeled in counterclockwise order
-^
We assume that indexing is done modulo
n
, so
and the above polygon P has
n
number of vertices
.
,..., , ,^
1
2 1 0
vn
v v v
P
.
0
v
= v
6
v
v
v
v
v
5
2 1 0
Labeling Convex Polygons