{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

DA19 - CSC 3102 Final Exam December 8 Monday 3:00 PM to...

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

View Full Document Right Arrow Icon
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
Image of page 1

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

View Full Document Right Arrow Icon
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
Image of page 2
B.B. Karki, LSU 0.3 CSC 3102 Dynamic Programming
Image of page 3

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

View Full Document Right Arrow Icon
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 Floyd Floyd’ s algorithm for all-pairs shortest paths Constructing an optimal binary search tree.
Image of page 4
B.B. Karki, LSU 0.5 CSC 3102 Binomial Coefficient Binomial formula: Binomial formula: 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 0 k k -1 …. 2 1 0
Image of page 5

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

View Full Document Right Arrow Icon
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 0 // 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 )
Image of page 6
B.B. Karki, LSU 0.7 CSC 3102 Warshall’s 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, t ij is 0 . Performing traversal (DFS or BFS) for every vertex as a starting point yields the transitive closure in its entirety.
Image of page 7

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

View Full Document Right Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern