Lecture 01 - 3 September 2013
- Change of text book - Algorithms, S. Dasgupta, C. Papadimitriou, U. Vazirani
- Will schedule workshop sessions starting next week
- introduce TA's - Tim Kopp (graduate TA), Yan Xing & Sean Esterkin (undergraduate TAs)
Class rules:
Grading: Your final grade will be based on 1/2 exams and in-class quizzes and 1/2 assignments.
Students requiring accomodations for testing or classroom participation should notify the instructor at the start of the semester, and suitable arrangements will be made.
Assignment due dates and quizzes are not intended to be scheduled on religious holidays; if one is scheduled in error, please notify the instructor so it can be rescheduled.
Homework Rules: You may work on your own or with other students in the class on the homework problems, but you must each write up your solutions separately, without any written aid. In other words, do not write up your final solution while actively collaborating, and do not refer to any notes you made while collaborating.
Your assignment must clearly indicate the names of the other students with whom you worked. Assignments are due at the start of class on the due date, and should be turned in in printed form.
Assignments that do not require creating an executable program should be typed or neatly writing using block letters (not cursive); points will be deducted for assignments that are hard to read. Late assignments will be accepted only under the following conditions:
- Serious illness, as demonstrated by a medical excuse signed by a medical professional.
- Out of town travel for university purposes, such as attending a scientific conference or playing on a university sports team. In all such cases, the instructor must be notified 48 hours in advance of the deadline of the reason for the delay.
Being unable to complete an assignment on time for reasons such as vacation travel or non-university activies is not an acceptable excuse. The grade for late assignments will be reduced by 20% per day late.
Academic Honesty: Turning in work that was copied from another person, the internet, or any other source without explicit citation of the original creator(s) is plagerism.
All cases of plagerism will be referred to the university Council on Academic Honesty. Punishments for plagerism include failing the class and expulsion from the university.
------------------------------------------------------------------------
[DPV Ch 0 and Sec. 1.2.3]
Origin of algorithms
Al Khwarizmi - 9th century Baghdad scholar
- step by step recipes for addition, multiplication, square roots, pi
Leonardo Fibonacci - 15th century Italian mathematician (600 years later!)
promoted Al Khwarizmi's work (and arabic positional notation)
What is Fibonacci most remembered for today?
function fib1(n)
if n = 0: return 0
if n = 1: return 1
return fib1(n-1) + fib1(n-2)
3 key questions about any algorithm:
1. Is it correct?
2. How much time does it take as a function of its input n?
Note: sometimes we n to be the value of an integer input,
other times we take it to be the *length* of the input.
For fib1(n), what is T(n)?
T(n) = T(n-1) + T(n-2) + 3
so -- just about the same as the value of F(n)!
Claim: F(n) >= r^(n-2) for some r > 1 for n>=2
(We will figure out what r should be while proving the claim.)
Proof by induction.
What are the parts of a proof by induction?
Base case: F(2) = F(1)+F(0) = 1 + 1 = 2
r^(n-2) = r^(2-2) = r^0 = 1
2 >= 1 okay!
Inductive case:
Assuming?
F(n) >= r^(n-2)
F(n-1) >= r^(n-3)
Prove?
F(n+1) >= r^(n-1)
Steps?
F(n+1) = F(n) + F(n-1)
>= r^(n-2) + r^(n-3)
Hmmm. We want to get r^(n-1), but instead we have a sum of two terms.
What to do?
Well, do we need to prove this for ALL r, or only for SOME PARTICULAR r?
Right, some particular r.
So, let's see if we can just solve for that special r such that
r^(n-2) + r^(n-3) = r^(n-1)
Let's simplify a bit by multiplying both sides by r^3.
r^3r^(n-2) + r^3r^(n-3) = r^3r^(n-1)
r^(n+1) + r^n = r^(n+2)
We got rid of the negative signs in the exponents, but we still have those
n's hanging around. The value of r shouldn't depend on n.
What could we divide each side by to get rid of the n's?
Right: divide each side by r^n.
r + 1 = r^2
Wow! If this equation has a solution, we are home free! Let's write this equation
in standard form (equal to 0):
-r^2 + r + 1 = 0
Now, if got through 10th grade you know how to solve a quadratic equation. What do we use?
Right, the quadratic formula!
r = (b +/- sqrt(b^2 - 4ac)) / 2a
r = (1 +/- sqrt(1 + 4)) / 2 = (1 +/- sqrt(5))/2
Which root do we want, the positive or negative one?
r = (1 + sqrt(5))/2
Therefore, for this particular value of r,
F(n+1) = F(n) + F(n-1)
>= r^(n-2) + r^(n-3) = r^(n-1)
which completes the inductive step.
****************************************
Linear time algorithm for Fib - first example of dynamic programming
function fib2(n)
if n = 0: return 0
create an array f[0..n]
for i=2 to n:
f[i] = f[i-1] + f[i-2]
return f[n]
Running time? Linear in n.
****************************************
Moore's Law no match for Algorithmic improvements!
Moore's law: # transistors doubles every 2 years
approximately: speed doubles every 2 years
(now: thermal limit on clock speed)
MIPS = million instructions per second
1971 - Intel 4040 - 0.1 MIPS
1972 - IBM 370 - 1 MIPS
1985 - Intel 386DX - 10 MIPS
1987 - Motorola 68060 - 100 MIPS
1999 - Intel Pentium 2 - 2,000 MIPS
2008 - Intel i7 - 80,000 MIPS
2011 - Intel i7 extreme - 180,000 MIPS
Exercise:
biggest N that can be found in 1 minute and 1 hour using fib1 vs fib2