[ACM-ICPC] Top-down & Bottom-up
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

[ACM-ICPC] Top-down & Bottom-up

on

  • 799 views

 

Statistics

Views

Total Views
799
Views on SlideShare
799
Embed Views
0

Actions

Likes
0
Downloads
11
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution-ShareAlike LicenseCC Attribution-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

[ACM-ICPC] Top-down & Bottom-up Presentation Transcript

  • 1. Top-down & Bottom-up 郭至軒(KuoE0) KuoE0.tw@gmail.com KuoE0.ch
  • 2. Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) http://creativecommons.org/licenses/by-sa/3.0/ Latest update: Feb 27, 2013
  • 3. Top-down將大問題化為小問題,再回溯求解。
  • 4. Top-down將大問題化為小問題,再回溯求解。
  • 5. Top-down將大問題化為小問題,再回溯求解。
  • 6. Bottom-up由已知解決小問題,逐步推移至大問題。
  • 7. Bottom-up由已知解決小問題,逐步推移至大問題。
  • 8. Recursion利用同樣的方法不斷的細分問題或 近答案。 易有太極,是生兩儀。兩儀生四象,四象生八卦。《易傳》
  • 9. Fibonacci Sequencefib(5)
  • 10. Fibonacci Sequencefib(5)fib(4) fib(3)
  • 11. Fibonacci Sequencefib(5)fib(4) fib(3)fib(3) fib(2)
  • 12. Fibonacci Sequencefib(5)fib(4) fib(3)fib(3) fib(2)fib(2) fib(1)
  • 13. Fibonacci Sequencefib(5)fib(4) fib(3)fib(3) fib(2)fib(2) fib(1)fib(1) fib(0)
  • 14. Fibonacci Sequencefib(5)fib(4) fib(3)fib(3) fib(2)fib(2) 1 fib(1)fib(1) 1 fib(0) 0
  • 15. Fibonacci Sequencefib(5)fib(4) fib(3)fib(3) 2 fib(2)fib(2) 1 fib(1) 1fib(1) 1 fib(0) 0
  • 16. Fibonacci Sequencefib(5)fib(4) fib(3)fib(3) 2 fib(2)fib(2) 1 fib(1) 1 fib(1) fib(0)fib(1) 1 fib(0) 0
  • 17. Fibonacci Sequencefib(5)fib(4) 3 fib(3)fib(3) 2 fib(2) 1fib(2) 1 fib(1) 1 fib(1) 1 fib(0) 0fib(1) 1 fib(0) 0
  • 18. Fibonacci Sequencefib(5)fib(4) 3 fib(3)fib(3) 2 fib(2) 1 fib(2) fib(1)fib(2) 1 fib(1) 1 fib(1) 1 fib(0) 0fib(1) 1 fib(0) 0
  • 19. Fibonacci Sequencefib(5)fib(4) 3 fib(3)fib(3) 2 fib(2) 1 fib(2) fib(1)fib(2) 1 fib(1) 1 fib(1) 1 fib(0) 0 fib(1) fib(0)fib(1) 1 fib(0) 0
  • 20. Fibonacci Sequencefib(5)fib(4) 3 fib(3)fib(3) 2 fib(2) 1 fib(2) 1 fib(1)fib(2) 1 fib(1) 1 fib(1) 1 fib(0) 0 fib(1) 1 fib(0) 0fib(1) 1 fib(0) 0
  • 21. Fibonacci Sequencefib(5) 5fib(4) 3 fib(3) 2fib(3) 2 fib(2) 1 fib(2) 1 fib(1) 1fib(2) 1 fib(1) 1 fib(1) 1 fib(0) 0 fib(1) 1 fib(0) 0fib(1) 1 fib(0) 0
  • 22. int fib( int x ) { if ( x <= 0 ) return 0; if ( x == 1 ) return 1; return fib( x - 1 ) + fib( x - 2 );}int main() { int ret = fib( 10 ); return 0;}
  • 23. Iteration不斷的利用已知,持續的求出結果以 近答案。 道生一,一生二,二生三,三生萬物。《老子》
  • 24. Fibonacci Sequence 0 1
  • 25. Fibonacci Sequence 0 1 1
  • 26. Fibonacci Sequence 0 1 1 2
  • 27. Fibonacci Sequence 0 1 3 1 2
  • 28. Fibonacci Sequence 0 1 3 1 2 5
  • 29. int main() { int f0 = 0, f1 = 1, f2; for ( int i = 0; i < 10; ++i ) { f2 = f0 + f1; f0 = f1, f1 = f2; } return 0;}
  • 30. 遞迴只應天上有,凡人應當用迴圈。
  • 31. Practice Now POJ 1664 - 放苹果
  • 32. reference• http://www.csie.ntnu.edu.tw/~u91029/ IterativeRecursive.html
  • 33. Thank You for Your Listening.