Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Government Engineering College, Rajkot

Computer Engineering Department


Subject: Analysis and Design of Algorithms
Subject Code: 3150703
B.E. Semester: 5th

Assignment – Dynamic Programming

1. Solve using dynamic Making Change Algorithm:

(a) Available denominations 2, 3, 5 and Amount = 7


(b) Available denominations 1, 3, 4, 7 and Amount = 12
(c) Available denominations 9, 6, 5, 1 and Amount = 11

2. Apply dynamic programming algorithm to solve 0/1 knapsack algorithm.

Item i1 i2 i3 i4
Weight w = 2 1 3 2
(a) Value v = 12 10 20 15
Capacity W = 5

Item i1 i2 i3 i4
Weight w = 4 7 5 3
(b) Value v = 40 42 25 12
Capacity W = 10

Item i1 i2 i3 i4 i5 i6
Weight w = 5 7 2 4 5 1
(c) Value v = 40 35 18 4 10 2
Capacity W = 15

Item i1 i2 i3 i4 i5
Weight w = 3 2 1 4 5
(d) Value v = 25 20 15 40 50
Capacity W = 6

3. Apply dynamic programming algorithm and find optimal parenthesization of


Chained Matrix Multiplication problem.

(a) Using dynamic programming find an optimal parenthesization of a matrix chain


product whose sequence of dimension is d = {5,10,3,12,5,50,6}

(b) Using dynamic programming find an optimal parenthesization of a matrix chain


product whose sequence of dimension is d = {30,35,15,5,10,20,25}
4. Apply dynamic programming algorithm to find Longest Common Subsequence

(a) Find Longest Common Sequence of s1 and s2 using Dynamic Programming.


S1= ABCDBACDF and S2 = CBAFDAC

(b) Find Longest Common Sequence of s1 and s2 using Dynamic Programming.


S1= 10010101 and S2 = 010110110

(c) Find Longest Common Subsequence of s1 and s2 using Dynamic Programming.


S1 = abbacdcba and S2 = bcdbbcaac

(d) Find Longest Common Subsequence of s1 and s2 using Dynamic Programming.


S1 = acagcacta and S2 = agtcacac

5. Apply dynamic programming algorithm to solve following Assembly Line


Scheduling problems.

Example 1

Example 2

6. Find all pair shortest path using Floyld’s algorithm

Example 1
Example 2

7. Suppose you have a rod of length n, and you want to cut up the rod and sell the pieces
in a way that maximizes total amount of money you get. A piece of length i is worth
pi. Design a dynamic programming algorithm to find the optimal way to split the rod.
Find maximum amount of money you get as well as split position.

You might also like