lec12 - CS 323/700 Lecture 12 Design and Analysis of...

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

View Full Document Right Arrow Icon
n CS 323/700 Lecture 12 o Design and Analysis of Algorithms Hoeteck Wee · [email protected] http://algorithms.qwriting.org/
Image of page 1

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

View Full Document Right Arrow Icon
Algorithmic paradigms GREEDY . build up a solution incrementally, myopically optimizing some local criterion. I challenge: which criterion? does it work? I real difficulty: perhaps there is no greedy strategy DIVIDE - AND - CONQUER . break up a problem into two independent sub-problems, recurse, and combine the solutions. I typically used to obtain better polynomial running time, e.g. O ( n 2 ) O ( n log n ) DYNAMIC PROGRAMMING . break up a problem into a series of overlapping sub-problems, then build up solutions to larger and larger sub-problems. I challenge: which sub-problem? I applications: Unix diff for comparing two files, Bellman-Ford for computing shortest paths, Smith-Waterman for sequence alignment, Viterbi for hidden Markov models Hoeteck Wee CS 323/700 Mar 22, 2010 2 / 13
Image of page 2
Computing the minimum PROBLEM . compute the minimum of n numbers p [ 0 ] , . . . , p [ n - 1 ] . ALGORITHM . def smallest (p): ans = p[0] for i in range(1, n): ans = min(ans, p[i]) return ans RUNNING TIME . O ( n ) I breaking problem down into n sub-problems I in the i ’th iteration, set ans to opt[i] := smallest(p[0],...,p[i]) I compute opt[i] as min(opt[i-1], p[i]) (takes O ( 1 ) time) I return opt[n-1] I
Image of page 3

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

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