Lecture 7 Paradigm #5 Greedy Algorithms
Ref. CLRS, Chap. 16
Example 1 (Making change) Suppose you buy
something of cost less than $5, and you get your
change in Canadian coins. How can you
minimize the number of coins returned to you?
Formally: Given x
Lecture 6 More Divide-Conquer
and Paradigm #4 Data Structure.
Today, we do more divide-and-conquer.
And, we do Algorithm design paradigm # 4:
invent or augment a data structure.
More divide and conquer:
powering a number
Problem: Compute an , where n i
Lecture 8. Paradigm #6 Dynamic Programming
Popularized by Richard Bellman ("Dynamic
Programming", Princeton University Press,
1957; call number QA 264.B36). Chapter 15 of
CLRS.
Typically, dynamic programming reduces the
complexity of a problem from 2n t
Lecture 11 Deterministic Selection
The goal is to determine the i'th smallest element from a list of n
elements in linear time. No random numbers are used.
The algorithm is due to Blum, Floyd, Pratt, Rivest, and Tarjan
(1973). The idea is the same as RA
Lecture 10. Paradigm #8:
Randomized Algorithms
Back to the majority problem (finding the
majority element in an array A).
FIND-MAJORITY(A, n)
while (true) do
randomly choose 1 I n;
if A[i] is the majority then
return (A[i]);
If there is a majority elem
Lecture 2
We have given O(n3), O(n2), O(nlogn) algorithms for the max sub-range problem. This
time, a linear time algorithm!
The idea is as follows: suppose we have found the maximum subrange sum for
x[1.n-1]. Now we have to find it for x[1.n]. There are
CS341, Winter, 2011
Algorithms
Instructor: Ming Li
David R. Cheriton School of Computer Science
University of Waterloo
http:/www.cs.uwaterloo.ca/~cs341/
The last century has witnessed the
development of a beautiful and elegant new
scientific field: the de
CS341, Winter, 2011
Algorithms
Instructor: Ming Li
David R. Cheriton School of Computer Science
University of Waterloo
http:/www.cs.uwaterloo.ca/~cs341/
The last century has witnessed the
development of a beautiful and elegant new
scientific field: the de