lec21 - Click to edit Master subtitle style Sundar B CS...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon

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

View Full Document Right Arrow Icon

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

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

Unformatted text preview: Click to edit Master subtitle style 2/7/11 Sundar B. CS C341 / I S C361 Data Structures & Algorithms Algorithm Design Techniques Top-Down Design and Divide & Conquer- Limitation Divide & Conquer with Memoization- Examples- Fibonacci Sequence- 0,1 Knapsack 11 2/7/11 Sundar B. 2/7/11 Sundar B. Top Down Design And Divide & Conquer Sub-problems may be identical But design structure may not recognize / reconcile them Results in repeated work Consider the problem of computing the Nth term of the Fibonacci Sequence 2/7/11 22 Sundar B. 2/7/11 Sundar B. Example – Fibonacci Sequence 2/7/11 33 Sundar B. { 3 4 E 0 6 C 7 3 -8 1 3 2 -4 2 7 5 -B F 1 3 -B F 6 B D 4 3 6 A F 3 } F(N) F(N-1) F(N-2) F(N-3) F(N-2) F(N-3) F(N-4) … … … … Overlapping Sub- Problems F(N) { if (N<=1) return 1; else return F(N-1) + F(N- 2); } 2/7/11 Sundar B. Example – Fibonacci Sequence 2/7/11 44 Sundar B. { 3 4 E 0 6 C 7 3 -8 1 3 2 -4 2 7 5 -B F 1 3 -B F 6 B D 4 3 6 A F 3 } F(N) F(N-1) F(N-2) F(N-3) F(N-2) F(N-3) F(N-4) … … … … F(N) { if (N<=1) return 1; else return F(N-1) + F(N- 2); } How many calls?...
View Full Document

{[ snackBarMessage ]}

Page1 / 12

lec21 - Click to edit Master subtitle style Sundar B CS...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online