Lecture # 13 - New
Lecture # 13 - New
Decide on : algorithm
design techniques etc.
Design an algorithm
Prove correctness
Read Chapter 8
Dynamic Programming
True or false?
Every algorithm that contains a divide step and
a conquer step is a divide-and-conquer
algorithm.
Answer: No
A dynamic programming contains a divide step
and a conquer step and may not be a divide-
and-conquer algorithm.
is so slow?
2. return n
3.else return FIB(n-1) + FIB(n-2)
ALGORITHM ITERFIB(n)
// Input: A positive number n
//Output: nth Fibonacci term
1.F[0] 0
2.F[1] 1
3.for i 2 to n do
4. F[i] F[i-1] + F[(i-2]
5.return
Department of Computer F[n]
Science
New designing technique build from the idea of divide and conquer
Time Complexity:
Why Exponential?
Can we reduce this complexity from
exponential to polynomial?
Initialization
Why
C(n, 0) = C(n, n) = 1
Time complexity:
If there are polynomial number of sub-problems.
If each sub-problem can be computed in polynomial
time.
Then the solution of whole problem can be found in
polynomial time.
Remark:
Greedy also applies a top-down strategy but
usually on one sub-problem so that the order of
computation is clear
table.
“Programming” here means “planning”. “Programming” refers to a
tabular method, not to writing computer code.
Invented by American mathematician Richard Bellman in the 1950s to
once
final state of the table will be (or contain) solution