61a extra lecture 2
play

61A Extra Lecture 2 Thursday, February 5 Announcements 2 - PowerPoint PPT Presentation

61A Extra Lecture 2 Thursday, February 5 Announcements 2 Announcements If you want 1 unit (pass/no pass) of credit for this CS 98, you need to: 2 Announcements If you want 1 unit (pass/no pass) of credit for this CS 98, you need to:


  1. 61A Extra Lecture 2 Thursday, February 5

  2. Announcements 2

  3. Announcements • If you want 1 unit (pass/no pass) of credit for this CS 98, you need to: 2

  4. Announcements • If you want 1 unit (pass/no pass) of credit for this CS 98, you need to: § Enroll in "Additional Topics on the Structure and Interpretation of Computer Programs" 2

  5. Announcements • If you want 1 unit (pass/no pass) of credit for this CS 98, you need to: § Enroll in "Additional Topics on the Structure and Interpretation of Computer Programs" § Course control number: 25709 2

  6. Announcements • If you want 1 unit (pass/no pass) of credit for this CS 98, you need to: § Enroll in "Additional Topics on the Structure and Interpretation of Computer Programs" § Course control number: 25709 • Extra Homework 1 due Thursday 2/12 @ 11:59pm 2

  7. Dice

  8. Hog: The End Game 4

  9. Hog: The End Game You: 98 Them: 99 4

  10. Hog: The End Game You: 98 You: 92 Them: 99 Them: 99 4

  11. Hog: The End Game You: 98 You: 92 You: 88 Them: 99 Them: 99 Them: 99 4

  12. Hog: The End Game You: 98 You: 92 You: 88 You: 80 Them: 99 Them: 99 Them: 99 Them: 99 4

  13. Hog: The End Game You: 98 You: 92 You: 88 You: 80 Them: 99 Them: 99 Them: 99 Them: 99 What is the chance that I'll score at least k points rolling n six-sided dice? 4

  14. Hog: The End Game You: 98 You: 92 You: 88 You: 80 Them: 99 Them: 99 Them: 99 Them: 99 What is the chance that I'll score at least k points rolling n six-sided dice? S n : Score from rolling n dice : A single outcome of rolling once t 4

  15. Hog: The End Game You: 98 You: 92 You: 88 You: 80 Them: 99 Them: 99 Them: 99 Them: 99 What is the chance that I'll score at least k points rolling n six-sided dice? 6 X S n : Score from rolling n dice P ( S n > k ) = P ( t ) · P ( S n − 1 > k − t ) : A single outcome of rolling once t =2 t 4

  16. Hog: The End Game You: 98 You: 92 You: 88 You: 80 Them: 99 Them: 99 Them: 99 Them: 99 What is the chance that I'll score at least k points rolling n six-sided dice? 6 X S n : Score from rolling n dice P ( S n > k ) = P ( t ) · P ( S n − 1 > k − t ) : A single outcome of rolling once t =2 t (assuming k > 1) 4

  17. Hog: The End Game You: 98 You: 92 You: 88 You: 80 Them: 99 Them: 99 Them: 99 Them: 99 What is the chance that I'll score at least k points rolling n six-sided dice? 6 X S n : Score from rolling n dice P ( S n > k ) = P ( t ) · P ( S n − 1 > k − t ) : A single outcome of rolling once t =2 t (assuming k > 1) The chance to score at least k in n rolls can be computed using tree recursion! 4

  18. Hog: The End Game You: 98 You: 92 You: 88 You: 80 Them: 99 Them: 99 Them: 99 Them: 99 What is the chance that I'll score at least k points rolling n six-sided dice? 6 X S n : Score from rolling n dice P ( S n > k ) = P ( t ) · P ( S n − 1 > k − t ) : A single outcome of rolling once t =2 t (assuming k > 1) The chance to score at least k in n rolls can be computed using tree recursion! Sum over each possible dice outcome t that does not pig out : 
 The chance to roll t times the chance to score at least k - t points using n - 1 rolls. 4

  19. Hog: The End Game You: 98 You: 92 You: 88 You: 80 Them: 99 Them: 99 Them: 99 Them: 99 What is the chance that I'll score at least k points rolling n six-sided dice? 6 X S n : Score from rolling n dice P ( S n > k ) = P ( t ) · P ( S n − 1 > k − t ) : A single outcome of rolling once t =2 t (assuming k > 1) The chance to score at least k in n rolls can be computed using tree recursion! Sum over each possible dice outcome t that does not pig out : 
 The chance to roll t times the chance to score at least k - t points using n - 1 rolls. Base case : The chance to score at least 0 in 0 rolls is 1 (guaranteed) 4

  20. Hog: The End Game You: 98 You: 92 You: 88 You: 80 Them: 99 Them: 99 Them: 99 Them: 99 What is the chance that I'll score at least k points rolling n six-sided dice? 6 X S n : Score from rolling n dice P ( S n > k ) = P ( t ) · P ( S n − 1 > k − t ) : A single outcome of rolling once t =2 t (assuming k > 1) The chance to score at least k in n rolls can be computed using tree recursion! Sum over each possible dice outcome t that does not pig out : 
 The chance to roll t times the chance to score at least k - t points using n - 1 rolls. Base case : The chance to score at least 0 in 0 rolls is 1 (guaranteed) Base case : The chance to score more than 0 in 0 rolls is 0 (impossible) 4

  21. Hog: The End Game You: 98 You: 92 You: 88 You: 80 Them: 99 Them: 99 Them: 99 Them: 99 What is the chance that I'll score at least k points rolling n six-sided dice? 6 X S n : Score from rolling n dice P ( S n > k ) = P ( t ) · P ( S n − 1 > k − t ) : A single outcome of rolling once t =2 t (assuming k > 1) The chance to score at least k in n rolls can be computed using tree recursion! Sum over each possible dice outcome t that does not pig out : 
 The chance to roll t times the chance to score at least k - t points using n - 1 rolls. Base case : The chance to score at least 0 in 0 rolls is 1 (guaranteed) Base case : The chance to score more than 0 in 0 rolls is 0 (impossible) (Demo) 4

  22. Memoization

  23. Recursive Computation of the Fibonacci Sequence Our first example of tree recursion: 6

  24. Recursive Computation of the Fibonacci Sequence def fib (n): Our first example of tree recursion: if n == 0 : return 0 elif n == 1 : return 1 else : return fib(n- 2 ) + fib(n- 1 ) 6

  25. Recursive Computation of the Fibonacci Sequence def fib (n): Our first example of tree recursion: if n == 0 : return 0 elif n == 1 : return 1 else : return fib(n- 2 ) + fib(n- 1 ) 6 http://en.wikipedia.org/wiki/File:Fibonacci.jpg

  26. Recursive Computation of the Fibonacci Sequence def fib (n): Our first example of tree recursion: if n == 0 : return 0 elif n == 1 : fib(5) return 1 else : return fib(n- 2 ) + fib(n- 1 ) 6 http://en.wikipedia.org/wiki/File:Fibonacci.jpg

  27. Recursive Computation of the Fibonacci Sequence def fib (n): Our first example of tree recursion: if n == 0 : return 0 elif n == 1 : fib(5) return 1 else : return fib(n- 2 ) + fib(n- 1 ) fib(3) 6 http://en.wikipedia.org/wiki/File:Fibonacci.jpg

  28. Recursive Computation of the Fibonacci Sequence def fib (n): Our first example of tree recursion: if n == 0 : return 0 elif n == 1 : fib(5) return 1 else : return fib(n- 2 ) + fib(n- 1 ) fib(3) fib(4) 6 http://en.wikipedia.org/wiki/File:Fibonacci.jpg

  29. Recursive Computation of the Fibonacci Sequence def fib (n): Our first example of tree recursion: if n == 0 : return 0 elif n == 1 : fib(5) return 1 else : return fib(n- 2 ) + fib(n- 1 ) fib(3) fib(4) fib(1) fib(2) fib(0) fib(1) 1 0 1 6 http://en.wikipedia.org/wiki/File:Fibonacci.jpg

  30. Recursive Computation of the Fibonacci Sequence def fib (n): Our first example of tree recursion: if n == 0 : return 0 elif n == 1 : fib(5) return 1 else : return fib(n- 2 ) + fib(n- 1 ) fib(3) fib(4) fib(1) fib(2) fib(2) fib(3) fib(0) fib(1) 1 fib(0) fib(1) fib(1) fib(2) 0 1 fib(0) fib(1) 0 1 1 0 1 6 http://en.wikipedia.org/wiki/File:Fibonacci.jpg

  31. Recursive Computation of the Fibonacci Sequence def fib (n): Our first example of tree recursion: if n == 0 : return 0 elif n == 1 : fib(5) return 1 else : return fib(n- 2 ) + fib(n- 1 ) fib(3) fib(4) fib(1) fib(2) fib(2) fib(3) fib(0) fib(1) 1 fib(0) fib(1) fib(1) fib(2) 0 1 fib(0) fib(1) 0 1 1 0 1 6 http://en.wikipedia.org/wiki/File:Fibonacci.jpg

  32. Recursive Computation of the Fibonacci Sequence def fib (n): Our first example of tree recursion: if n == 0 : return 0 elif n == 1 : fib(5) return 1 else : return fib(n- 2 ) + fib(n- 1 ) fib(3) fib(4) fib(1) fib(2) fib(2) fib(3) fib(0) fib(1) 1 fib(0) fib(1) fib(1) fib(2) 0 1 fib(0) fib(1) 0 1 1 0 1 6 http://en.wikipedia.org/wiki/File:Fibonacci.jpg

  33. Recursive Computation of the Fibonacci Sequence def fib (n): Our first example of tree recursion: if n == 0 : return 0 elif n == 1 : fib(5) return 1 else : return fib(n- 2 ) + fib(n- 1 ) fib(3) fib(4) fib(1) fib(2) fib(2) fib(3) fib(0) fib(1) 1 fib(0) fib(1) fib(1) fib(2) 0 1 fib(0) fib(1) 0 1 1 0 1 6 http://en.wikipedia.org/wiki/File:Fibonacci.jpg

  34. Recursive Computation of the Fibonacci Sequence def fib (n): Our first example of tree recursion: if n == 0 : return 0 elif n == 1 : fib(5) return 1 else : return fib(n- 2 ) + fib(n- 1 ) fib(3) fib(4) fib(1) fib(2) fib(2) fib(3) fib(0) fib(1) 1 fib(0) fib(1) fib(1) fib(2) 0 1 fib(0) fib(1) 0 1 1 0 1 6 http://en.wikipedia.org/wiki/File:Fibonacci.jpg

  35. Recursive Computation of the Fibonacci Sequence def fib (n): Our first example of tree recursion: if n == 0 : return 0 elif n == 1 : fib(5) return 1 else : return fib(n- 2 ) + fib(n- 1 ) fib(3) fib(4) fib(1) fib(2) fib(2) fib(3) fib(0) fib(1) 1 fib(0) fib(1) fib(1) fib(2) 0 1 fib(0) fib(1) 0 1 1 0 1 6 http://en.wikipedia.org/wiki/File:Fibonacci.jpg

  36. Recursive Computation of the Fibonacci Sequence def fib (n): Our first example of tree recursion: if n == 0 : return 0 elif n == 1 : fib(5) return 1 else : return fib(n- 2 ) + fib(n- 1 ) fib(3) fib(4) fib(1) fib(2) fib(2) fib(3) fib(0) fib(1) 1 fib(0) fib(1) fib(1) fib(2) 0 1 fib(0) fib(1) 0 1 1 0 1 6 http://en.wikipedia.org/wiki/File:Fibonacci.jpg

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend