DA19 - B.B. Karki, LSU 0.1 CSC 3102 CSC 3102: Final Exam...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: B.B. Karki, LSU 0.1 CSC 3102 CSC 3102: Final Exam December 8, Monday 3:00 PM to 5:00 PM 213 Tureaud Hall B.B. Karki, LSU 0.2 CSC 3102 Algorithm Design Techniques Brute force Divide-and-conquer Decrease-and-conquer Transform-and-conquer Space-and-time tradeoffs Dynamic programming Greedy techniques B.B. Karki, LSU 0.3 CSC 3102 Dynamic Programming B.B. Karki, LSU 0.4 CSC 3102 Basics Dynamic Programming is a general algorithm design technique: Dynamic Programming is a general algorithm design technique: Invented by Richard Bellman in the 1950s to solve optimization problems Invented by Richard Bellman in the 1950s to solve optimization problems Programming Programming here means here means planning planning . Main idea: Main idea: Solve several smaller (overlapping) Solve several smaller (overlapping) subproblems subproblems Record solutions in a table so that each Record solutions in a table so that each subproblem subproblem is solved only once is solved only once Final state of the table will be (or contain) solution. Final state of the table will be (or contain) solution. Examples: Examples: Computing a binomial coefficient Computing a binomial coefficient Warshall Warshall s s algorithm for transitive closure algorithm for transitive closure Floyd Floyd s algorithm for all-pairs shortest paths s algorithm for all-pairs shortest paths Constructing an optimal binary search tree. Constructing an optimal binary search tree. B.B. Karki, LSU 0.5 CSC 3102 Binomial Coefficient Binomial formula: Binomial formula: Two properties are: Two properties are: Solving the recurrence relation by the dynamic programming method: Solving the recurrence relation by the dynamic programming method: Record the values of the binomial coefficients in a table ( Record the values of the binomial coefficients in a table ( n +1 by +1 by k +1) +1) ( a + b ) n = C ( n ,0) a n + ......... + C ( n , k ) a n k b k + .......... + C ( n , n ) b n C ( n , k ) = C ( n 1, k 1) + C ( n 1, k ) C ( n ,0) = C ( n , n ) = 1 for n > k > 0 C(n,k) 1 n C(n-1,k) C(n-1,k-1) 1 n -1 1 2 1 2 1 1 1 1 k k-1 . 2 1 B.B. Karki, LSU 0.6 CSC 3102 Pseudocode Algorithm Binomial ( n, k ) // Computes C(n,k) by the dynamic programming algorithm // Input: A pair of nonnegative integers n k // Output: The value of C(n,k) for i 1 to n do for j 1 to min(i, k) do if j = 0 or j = i C[i, j] 1 else C[i, j] C[i - 1, j - 1] + C[i - 1, j] return C [ n, k] Time efficiency: ( nk ) Space efficiency: ( nk ) B.B. Karki, LSU 0.7 CSC 3102 Warshalls Algorithm The transitive closure of a directed graph is the n-by- n boolean matrix T = { t ij }, in which the element t ij in the i th row and the j th column is 1 if there exists a directed path from the i th vertex to j th vertex; otherwise,...
View Full Document

This note was uploaded on 10/06/2009 for the course CSC 3102 taught by Professor Kraft,d during the Fall '08 term at LSU.

Page1 / 18

DA19 - B.B. Karki, LSU 0.1 CSC 3102 CSC 3102: Final Exam...

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

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