Ms 000000000
-
Upload
anam-manzoor -
Category
Documents
-
view
230 -
download
2
description
Transcript of Ms 000000000
CS702: Advance Algorithm Analysis and Design
Assignment No.2 MS (CS), Fall 2014 Maximum Points: 50
20+20+9=49
Question No. 1 (20 Points) 20
Use Brute Force Method to find an optimal solution for the 0-1 Knapsack problem.Item weight value knapsack capacity W = 201 2 32 3 43 4 54 5 8
59 10
12345
345810
23459
Capacity = 20
Dynamic Programming Method:
Keep = 0
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 0
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 0
Keep = 1
Keep = 1
Keep = 1
Keep = 0
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 0
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 0
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 0
Keep = 0
Keep = 0
Keep = 0
Keep = 0
Keep = 0
Keep = 0
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Keep = 1
Let W = 20Final Solution: V[5, 20] = 26Item selected: [1, 3, 4, 5]
Brute Force Method:
ItemsSubsetTotal weightTotal Value
1
00
2{1}23
3{2}34
4{3}45
5{4}58
6{5}910
7{1,2}57
8{1,3}68
9{1,4}711
10{1,5}1113
11{2,3}79
12{2,4}812
13{2,5}1214
14{3,4}913
15{3,5}1315
16{4,5}1418
17{1,2,3}912
18{1,2,4}1015
19{1,2,5}1417
20{1,3,4}1116
21{1,3,5}1518
22{2,3,4}1217
23{2,3,5}1619
24{2,4,5}1722
25{3,4,5}1823
26{1,2,3,4}1420
27{1,2,3,5}1822
28{1,3,4,5}2026
29{1,2,4,5}1825
30{2,3,4,5}2127 not feasible
31{1,2,3,4,5}2330 not feasible
Question No. 2 (20 Points) 20
You have been given four matrices A1.A2.A3.A4 with p0=5, p1=4, p2=6, p3=2 and p4=7. You have to find m [1, 4].
Solution:
Main Diagonal:
Computing m [1, 2]:
Computing m [2, 3]:
Computing m [3, 4]:
Computing m [1, 3]:
Computing m [2, 4]:
Computing m [1, 4]:
Final Cost Matrix:012088158
048104
084
0
Order of Computation:15810
269
37
4
K,s Values Leading Minimum m[i, j]0113
022
03
0
Representing Order using Binary Tree
The above computation shows that the minimum cost for multiplying those four matrices is 158.
The optimal order for multiplication is, for.
158 for m[1,4]. and (1,3,4,5)giving maximum value
Question No. 3 (10 Points) 9
Read the attached research paper entitled The Automatic Construction ofPure Recurrence Relations, with this assignment very carefully. Answer the following question:
a. Which method is used for the construction of Pure Recurrence Relation?
Abstract:To generalize the hyper geometric functions we construct the method of pure recurrence relations, an improvement of a technique by Fasenmeyer suitable for automatic computer programming.
Geometrical interpretation and constructive proof for the existence of a pure recurrence relation for functions of the form:
(1)
Where a, s, b s are polynomials in; k, n and possibly other atoms;
We will denote these atoms as; k, y. However these polynomials must be linearly dependent on k and n and their coefficients must be integers.
The functionsinclude most of the generalized hyper geometric functions:
(2)
Whereis the usual Pochhammer symbol such that
Where
A pure recurrence relation for (i) as a function of n is an expression of the form:
(3)
The coefficients of the termsare rational expressions in y. r is the order of the recurrence relation.
Problem of the construction of a recurrence relation in two parts:
1)
Finding V, the set of integer pairssuch that is a term of the recurrence relation.2) computing the coefficients
If the structure of the recurrence relation is known, if V is known, then thecan be found as solutions of a system of linear equations with polynomials as coefficients.
The method involves rewriting eachas
(4)
Whereis define as
(5)
The are rational expression. We can rewrite (3) as:
(6)
The nominator of the coefficient of.after expansion to a common denominator must vanish for each value of k. We call this nominator a polynomial in, with as coefficients polynomials in y and the, the associated polynomial of (3). To yield simple equations, it is wisest to get them by a judicious mixture of employing specific values of k and equating coefficients of powers of k to zero. More details can be found in [1, 2]. From now on we concentrate on finding the structure of the recurrence relation.