Solutions of Theory of Algorithms assignment3

Solutions of Theory of Algorithms assignment3 - Exercise...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Solutions of Theory of Algorithms Assignment 3 Exercise 15.2-1 1 2 3 4 5 6 1 0 150 330 405 1655 2010 2 0 360 330 2430 1950 3 0 180 930 1770 4 0 3000 1860 5 0 1500 6 0 Exercise 15.2-2 MATRIX-CHAIN-MULTIPLY( A , s , i, j ) if j=1 then return Multiply ( A i , A j ) else MATRIX-CHAIN-MULTIPLY ( A, s , i , s [ i , j ]) MATRIX-CHAIN-MULTIPLY ( A, s , s [ i , j ] + 1, j ) Exercise 15.4-4 As elements of c at index i and j is computed using elements from I, i-1, j, and j-1, therefore we can compute the length of an LCS using only 2 · min( m , n ) entries in the c table
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Exercise 15.4-5 To find the longest monotonically increasing subsequence (LMIS) of a sequence of n numbers, we can sort them in an increasing order and store them in another array. Then, we use the LCS function as follows: LMIS (s) T=s //t is temporary array Sorted_T= sort (T) //sort in increasing order LCS-LENGTH (s, sorted_T)
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Exercise 15.5-2 Exercise 15.5-3 The asymptotic running time does not depend only on the computation of line 8, we will still need the three nested loops. So the running time is O ( n 3 ). Exercise 16.1-2 Select the last activity to start that is compatible with all previously selected activities is the mirror algorithm of selecting the first activity to finish. It is the same idea as the proposed algorithm in chapter 16. It is greedy algorithm as it looks for the local optimal solution Exercise 16.1-3 Use GREEDY-ACTIVITY-SELECTOR function which returns a maximum-size set of mutually compatible activities, and assign these activities to a lecture hall. Repeat these two steps until all activities are settled....
View Full Document

Page1 / 2

Solutions of Theory of Algorithms assignment3 - Exercise...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online