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

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

n CS 323/700 Lecture 12 o Design and Analysis of Algorithms Hoeteck Wee · [email protected] http://algorithms.qwriting.org/

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

View Full Document
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
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

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• 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.

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

• 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.

Dana University of Pennsylvania ‘17, Course Hero Intern

• 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.

Jill Tulane University ‘16, Course Hero Intern