Dynamic Programming�(Smart Recursion)
By
Sarfraz
Shortest paths in DAGS, revisited
Shortest paths in DAGS, revisited
Shortest paths in DAGS, revisited
Longest paths in DAGS, revisited
For Longest paths what changes we should make???
Longest paths in DAGS, revisited
For Longest paths what changes we should make???
Catalan Number Computation
Quiz - Catalan Number Computation
THE Catalan SEQUENCE : ��1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862, 16796, 58786, 208012, 742900, 2674440, 9694845, 35357670, 129644790, 477638700, 1767263190, 6564120420, 24466267020, 91482563640, 343059613650, 1289904147324, 4861946401452, ...
Quiz - Write the C++ RECURSIVE code to compute N’th Catalan number?
Catalan Number - Application
Total Possible Parenthesization with n brackets are ???
Quiz 2 – Google 2 Other applications of Catalan numbers???
Catalan Numbers
�
Tiling Problem
Tiling Problem
Fibonacci Numbers
Fib(N) = Fib(N-1) + Fib(N-2)�Fib(0) = 0�Fib(1) = 1
Fibonacci Numbers
��
��
FibTopDown
Largest Sum Contiguous Subarray (Stock Exchange Problem)
Largest Sum Contiguous Subarray
Largest Sum Contiguous Subarray (LSCS)
“Any LSCS will end at any index”
Kadane’s Algorithm
Longest increasing subsequences
5 | 2 | 8 | 6 | 3 | 6 | 9 | 7 |
Longest increasing subsequences
5 | 2 | 8 | 6 | 3 | 6 | 9 | 7 |
Longest increasing subsequences
5 | 2 | 8 | 6 | 3 | 6 | 9 | 7 |
Longest increasing subsequences
Longest path from S to D correspond �to Longest Increasing subsequence
Green edges has weight 0 and blue �and black edges has weight 1.
Longest increasing subsequences
Longest path from S to D correspond �to Longest Increasing subsequence
Longest increasing subsequences
Longest increasing subsequences
Longest increasing subsequences
Rod Cutting Problem
Rod Cutting Problem
Rod Cutting Problem
Rod Cutting Problem
Rod Cutting Problem
Rod Cutting Problem (Time Complexity)
Rod Cutting Problem � (Top Down approach)
Rod Cutting Problem � (Top Down approach)
Rod Cutting Problem� (Bottom Up Approach)
Rod Cutting Problem� Book Keeping??
Rod Cutting Problem� Book Keeping??
Rod Cutting Problem� Book Keeping??
Thank You