lec15 - Introduction to Algorithms 6.046J/18.401J LECTURE...

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

View Full Document Right Arrow Icon
November 7, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L15.1 Introduction to Algorithms 6.046J/18.401J L ECTURE 15 Dynamic Programming Longest common subsequence Optimal substructure Overlapping subproblems Prof. Charles E. Leiserson
Image of page 1

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

View Full Document Right Arrow Icon
November 7, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L15.2 Dynamic programming Design technique, like divide-and-conquer. Example: Longest Common Subsequence (LCS) Given two sequences x [1 . . m ] and y [1 . . n ] , find a longest subsequence common to them both.
Image of page 2
November 7, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L15.3 Dynamic programming Design technique, like divide-and-conquer. Example: Longest Common Subsequence (LCS) Given two sequences x [1 . . m ] and y [1 . . n ] , find a longest subsequence common to them both. “a” not “the”
Image of page 3

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

View Full Document Right Arrow Icon
November 7, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L15.4 Dynamic programming Design technique, like divide-and-conquer. Example: Longest Common Subsequence (LCS) Given two sequences x [1 . . m ] and y [1 . . n ] , find a longest subsequence common to them both. x : A B C B D A B y : B D C A B A “a” not “the”
Image of page 4
November 7, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L15.5 Dynamic programming Design technique, like divide-and-conquer. Example: Longest Common Subsequence (LCS) Given two sequences x [1 . . m ] and y [1 . . n ] , find a longest subsequence common to them both. x : A B C B D A B y : B D C A B A “a” not “the” BCBA = LCS( x , y ) functional notation, but not a function
Image of page 5

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

View Full Document Right Arrow Icon
November 7, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L15.6 Brute-force LCS algorithm Check every subsequence of x [1 . . m ] to see if it is also a subsequence of y [1 . . n ] .
Image of page 6
November 7, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L15.7 Brute-force LCS algorithm Check every subsequence of x [1 . . m ] to see if it is also a subsequence of y [1 . . 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.
Image of page 7

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

View Full Document Right Arrow Icon
November 7, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L15.8 Towards a better algorithm Simplification: 1. Look at the length of a longest-common subsequence.
Image of page 8
Image of page 9
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