Longest Common Subseq Conclusions DijkstraAlgorithm An example Iteration 13Q

Longest common subseq conclusions dijkstraalgorithm

This preview shows page 69 - 83 out of 90 pages.

Longest Common Subseq. . . . Conclusions Dijkstra’Algorithm: An example Iteration 13 Q = {} End of algorithm. COMP 6651 / Fall 2013 - B. Jaumard 45
Image of page 69
. . . . . . . . . . Dynamic Prog. . . . . . . . . . . . . . . . . Assembly-Line Scheduling . . . . . . . . . . . . . . Knapsack Pb . . . . . . . . . Shortest Path . . . . . . . . . . . . . . . . . . Longest Common Subseq. . . . Conclusions Longest Common Subsequence COMP 6651 / Fall 2013 - B. Jaumard 46
Image of page 70
. . . . . . . . . . Dynamic Prog. . . . . . . . . . . . . . . . . Assembly-Line Scheduling . . . . . . . . . . . . . . Knapsack Pb . . . . . . . . . Shortest Path . . . . . . . . . . . . . . . . . . Longest Common Subseq. . . . Conclusions Dynamic Programming Design technique, like divide-and-conquer. Example: Longest Common Subsequence (LCS) Given two sequences x [ 1 , 2 , . . . , m ] and y [ 1 , 2 , . . . , n ] , find a longest subsequence common to them both. “a” LCS, not “the” LCS LCS ( x , y ) = BCBA COMP 6651 / Fall 2013 - B. Jaumard 47
Image of page 71
. . . . . . . . . . Dynamic Prog. . . . . . . . . . . . . . . . . Assembly-Line Scheduling . . . . . . . . . . . . . . Knapsack Pb . . . . . . . . . Shortest Path . . . . . . . . . . . . . . . . . . Longest Common Subseq. . . . Conclusions Brute-force LCS algorithm Check every subsequence of x [ 1 , 2 , . . . , m ] to see if it is also a subsequence of y [ 1 , 2 , . . . , n ] . Analysis Checking = O ( n ) time per subsequence. 2 m subsequences of x (each bit-vector of length m determines a distinct subsequence of x ). Worst-case running time = O ( n 2 m ) = exponential time. COMP 6651 / Fall 2013 - B. Jaumard 48
Image of page 72
. . . . . . . . . . Dynamic Prog. . . . . . . . . . . . . . . . . Assembly-Line Scheduling . . . . . . . . . . . . . . Knapsack Pb . . . . . . . . . Shortest Path . . . . . . . . . . . . . . . . . . Longest Common Subseq. . . . Conclusions Towards a better algorithm Simplification: 1. Look at the length of a longest-common subsequence. 2. Extend the algorithm to find the LCS itself. Notation: Denote the length of a sequence s by | s | . Strategy: Consider prefixes of x and y . Define c [ i , j ] = | LCS ( x [ 1 , 2 , . . . , i ] , y [ 1 , 2 , . . . , j ]) | . Then, c [ m , n ] = | LCS ( x , y ) | . COMP 6651 / Fall 2013 - B. Jaumard 49
Image of page 73
. . . . . . . . . . Dynamic Prog. . . . . . . . . . . . . . . . . Assembly-Line Scheduling . . . . . . . . . . . . . . Knapsack Pb . . . . . . . . . Shortest Path . . . . . . . . . . . . . . . . . . Longest Common Subseq. . . . Conclusions Recursive Formulation COMP 6651 / Fall 2013 - B. Jaumard 50
Image of page 74
. . . . . . . . . . Dynamic Prog. . . . . . . . . . . . . . . . . Assembly-Line Scheduling . . . . . . . . . . . . . . Knapsack Pb . . . . . . . . . Shortest Path . . . . . . . . . . . . . . . . . . Longest Common Subseq. . . . Conclusions Proof (continued) COMP 6651 / Fall 2013 - B. Jaumard 51
Image of page 75
. . . . . . . . . . Dynamic Prog. . . . . . . . . . . . . . . . . Assembly-Line Scheduling . . . . . . . . . . . . . . Knapsack Pb . . . . . . . . . Shortest Path . . . . . . . . . . . . . . . . . . Longest Common Subseq. . . . Conclusions Dynamic Programming Hallmark #1 COMP 6651 / Fall 2013 - B. Jaumard 52
Image of page 76
. . . . . . . . . . Dynamic Prog. . . . . . . . . . . . . . . . . Assembly-Line Scheduling . . . . . . . . . . . . . . Knapsack Pb . . . . . . . . . Shortest Path . . . . . . . . . . . . . . . . . . Longest Common Subseq. . . . Conclusions Recursive Algorithm for LCS COMP 6651 / Fall 2013 - B. Jaumard 53
Image of page 77
. . . . . . . . . . Dynamic Prog. . . . . . . . . . . . . . . . . Assembly-Line Scheduling . . . . . . . . . . . . . . Knapsack Pb . . . . . . . . . Shortest Path . . . . . . . . . . . . . . . . . . Longest Common Subseq. . . . Conclusions Recursion Tree COMP 6651 / Fall 2013 - B. Jaumard 54
Image of page 78
. . . . . . . . . . Dynamic Prog. . . . . . . . . . . . . . . . . Assembly-Line Scheduling . . . . . . . . . . . . . . Knapsack Pb . . . . . . . . . Shortest Path . . . . . . . . . . . . . . . . . . Longest Common Subseq. . . . Conclusions Recursion Tree COMP 6651 / Fall 2013 - B. Jaumard 55
Image of page 79
. . . . . . . . . . Dynamic Prog. . . . . . . . . . . . . . . . . Assembly-Line Scheduling . . . . . . . . . . . . . . Knapsack Pb . . . . . . . . . Shortest Path . . . . . . . . . . . . . . . . . . Longest Common Subseq. . . . Conclusions Recursion Tree COMP 6651 / Fall 2013 - B. Jaumard 56
Image of page 80
. . . . . . . . . . Dynamic Prog. . . . . . . . . . . . . . . . . Assembly-Line Scheduling . . . . . . . . . . . . . . Knapsack Pb . . . . . . . . . Shortest Path . . . . . . . . . . . . . . . . . . Longest Common Subseq. . . . Conclusions Dynamic Programming Hallmark #2 COMP 6651 / Fall 2013 - B. Jaumard 57
Image of page 81
. . . . . . . . . . Dynamic Prog. . . . . . . . . . . . . . . . . Assembly-Line Scheduling . . . . . . . . . . . . . . Knapsack Pb . . . . . . . . . Shortest Path . . . . . . . . . . . . . . . . . . Longest Common Subseq. . . . Conclusions Memoization The term memoization was coined by Donald Michie in 1968 and is derived from the Latin word memorandum (to be remembered), and thus carries the meaning of turning [the results of] a function into something to be remembered.
Image of page 82
Image of page 83

You've reached the end of your free preview.

Want to read all 90 pages?

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

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes