Docsity

Algorithm Analysis and Design Final Exam, December 2008 - Prof. Edward Bosworth, Exams of Computer Architecture and Organization

Toggle sidebar
bg1
CPSC 5115 Algorithm Analysis and Design
FINAL EXAM Thursday, December 11, 2008
THIS TEST IS OPEN-BOOK, OPEN-NOTES.
SHOW ALL OF YOUR WORK ON EACH QUESTION. A CORRECT ANSWER, BY
ITSELF, WILL GET ONLY PARTIAL CREDIT. I MUST SEE HOW YOU GOT IT.
1. (10 points) This question concerns the use of Horspool’s Algorithm for string
matching. Compute the shift matrix for the word “ALGORITHM”.
2. (10 points) Compute the inverse of the 2-by-2 matrix
84
93
.
3. (20 points) Solve the following recursion
a) T(N) = 3T(N/27) + N2.
b) T(N) = 3T(N/27) + N3.
c) T(N) = 3T(N/27) + N + 15.
4. (20 points) Consider the matrix, at right, of costs
associated with assigning one of four jobs to one of
four workers (A, B, C, or D). We want to minimize
the total cost, subject to the constraint that each
worker is assigned exactly one job.
a) Derive the best quick lower bound on the cost of the
optimal selection.
b) Show a quick feasible solution that will serve as an upper bound on the optimal cost.
c) Derive an optimal assignment, given that it involves assignment of job 1 to worker D.
5. (20 points) Solve the following optimization problem. You are given a sack
with a capacity of 42 pounds. You are to maximize the value of items put
into the sack under the 0/1 constraint – either an item is put in or not.
There are seven items, with weight and values given by the following arrays
Weight[I] = { 20, 20, 10, 10, 5, 5, 2 }
Value[I] = { 40, 80, 30, 60, 25, 40, 14 }
6. (20 points) Consider the following directed graph on four vertices, represented by the
following edge weight matrix, with an empty entry indicating no such edge. Thus there is no
edge (1, 4) from vertex 1 to vertex 4; although there is an edge from vertex 4 to vertex 1.
Vertex 1 2 3 4
1 0 5 1
2 9 0 6 4
3 2 0 8
4 3 0
Use Floyd’s Algorithm to compute all shortest paths in this directed weighted graph. You may
use short–cuts to avoid computations when two vertices are identical.
1 2 3 4
A 8 6 2 4
B 6 7 11 10
C 3 5 7 6
D 5 10 12 9

Partial preview of the text

Download Algorithm Analysis and Design Final Exam, December 2008 - Prof. Edward Bosworth and more Exams Computer Architecture and Organization in PDF only on Docsity!

CPSC 5115 Algorithm Analysis and Design

FINAL EXAM Thursday, December 11, 2008

THIS TEST IS OPEN-BOOK, OPEN-NOTES.

SHOW ALL OF YOUR WORK ON EACH QUESTION. A CORRECT ANSWER, BY

ITSELF, WILL GET ONLY PARTIAL CREDIT. I MUST SEE HOW YOU GOT IT.

  1. (10 points) This question concerns the use of Horspool’s Algorithm for string matching. Compute the shift matrix for the word “ALGORITHM”.
  2. (10 points) Compute the inverse of the 2-by-2 matrix (^)       4 8 3 9 .
  3. (20 points) Solve the following recursion a) T(N) = 3T(N/27) + N^2. b) T(N) = 3T(N/27) + N^3. c) T(N) = 3T(N/27) + N + 15.
  4. (20 points) Consider the matrix, at right, of costs associated with assigning one of four jobs to one of four workers (A, B, C, or D). We want to minimize the total cost, subject to the constraint that each worker is assigned exactly one job. a) Derive the best quick lower bound on the cost of the optimal selection. b) Show a quick feasible solution that will serve as an upper bound on the optimal cost. c) Derive an optimal assignment, given that it involves assignment of job 1 to worker D.
  5. (20 points) Solve the following optimization problem. You are given a sack with a capacity of 42 pounds. You are to maximize the value of items put into the sack under the 0/1 constraint – either an item is put in or not. There are seven items, with weight and values given by the following arrays Weight[I] = { 20, 20, 10, 10, 5, 5, 2 } Value[I] = { 40, 80, 30, 60, 25, 40, 14 }
  6. (20 points) Consider the following directed graph on four vertices, represented by the following edge weight matrix, with an empty entry indicating no such edge. Thus there is no edge (1, 4) from vertex 1 to vertex 4; although there is an edge from vertex 4 to vertex 1. Vertex 1 2 3 4 1 0 5 1 2 9 0 6 4 3 2 0 8 4 3 0 Use Floyd’s Algorithm to compute all shortest paths in this directed weighted graph. You may use short–cuts to avoid computations when two vertices are identical.

A 8 6 2 4

B 6 7 11 10

C 3 5 7 6

D 5 10 12 9