The Beauty and Joy of Computing Lecture #10 Recursion II

Slides:



Advertisements
Similar presentations
Tree Recursion Traditional Approach. Tree Recursion Consider the Fibonacci Number Sequence: Time: , 1, 1, 2, 3, 5, 8, 13, 21,... /
Advertisements

§3 Dynamic Programming Use a table instead of recursion 1. Fibonacci Numbers: F(N) = F(N – 1) + F(N – 2) int Fib( int N ) { if ( N
Intro to Analysis of Algorithms. Algorithm “A sequence of unambiguous instructions for solving a problem, i.e., for obtaining a required output for any.
CS10 The Beauty and Joy of Computing Lecture #7 Algorithmic Complexity One million Wi-Fi devices isn’t cool. You know what’s cool? A Billion.
Use of Computer Technology in Education Course Management Systems Learning Management Systems Classroom Teaching Technology Modeling and Simulation and.
FIBONACCI Lecture 23 CS2110 – Spring 2015 Fibonacci (Leonardo Pisano) ? Statue in Pisa Italy And recurrences.
CS10 The Beauty and Joy of Computing Lecture #11 : Recursion II Microsoft filed a patent that proposed to use the 3D depth camera to estimate.
6.001 SICP – September Introduction
CS39N The Beauty and Joy of Computing Lecture #11 Recursion II Researchers at Microsoft, UW and U Toronto have come up with a technique to interact.
CS10 The Beauty and Joy of Computing Lecture #25 : Tree Recursion The newly released (and much- hyped) Microsoft Kinect system for the XBOX.
CS39N The Beauty and Joy of Computing Lecture #11 Recursion III It has been a challenge to power electronic components implanted within a body.
CS10 The Beauty and Joy of Computing Lecture #11 : Recursion II Will Apple continue to thrall its users with outstanding technology amidst tons.
Great Theoretical Ideas in Computer Science.
Linear, Exponential, and Quadratic Functions. Write an equation for the following sequences.
Fibonacci numbers Fibonacci numbers:Fibonacci numbers 0, 1, 1, 2, 3, 5, 8, 13, 21, 34,... where each number is the sum of the preceding two. Recursive.
Great Theoretical Ideas in Computer Science.
Fibonacci Numbers, Polynomial Coefficients, and Vector Programs.
CS-2852 Data Structures LECTURE 12B Andrew J. Wozniewicz Image copyright © 2010 andyjphoto.com.
Computer Science: A Structured Programming Approach Using C1 6-9 Recursion In general, programmers use two approaches to writing repetitive algorithms.
Comp 245 Data Structures Recursion. What is Recursion? A problem solving concept which can be used with languages that support the dynamic allocation.
CS10 The Beauty and Joy of Computing Lecture #11 : Recursion II Instructor : Sean Morris Security Flaws in your OS
Fundamentals CSE 373 Data Structures Lecture 5. 12/26/03Fundamentals - Lecture 52 Mathematical Background Today, we will review: ›Logs and exponents ›Series.
Recursion. What is recursion? Rules of recursion Mathematical induction The Fibonacci sequence Summary Outline.
Week 6 - Monday.  What did we talk about last time?  Exam 1!  Before that:  Recursion.
Recursion. Math Review Given the following sequence: a 1 = 1 a n = 2*a n-1 OR a n+1 = 2*a n What are the values of the following? a 2 = a 3 = a 4 =
Today’s topics Orders of growth of processes Relating types of procedures to different orders of growth.
Chapter 5 – Functions II Outline Recursion Examples Using Recursion: The Fibonacci Series.
David Stotts Computer Science Department UNC Chapel Hill.
DATA STRUCTURES AND ALGORITHMS Lecture Notes 2 Prepared by İnanç TAHRALI.
“The coolest phones we’ve seen from the world’s largest mobile show so far include quad-core chips, larger screens, and even one with a projector built.
1Computer Sciences. 2 GROWTH OF FUNCTIONS 3.2 STANDARD NOTATIONS AND COMMON FUNCTIONS.
The Beauty and Joy of Computing Lecture #11 Recursion II Toby Shachman created this amazing spatial programming language called “Recursive Drawing” that.
The Beauty and Joy of Computing Lecture #7 Algorithms II minors-delete-activity/story?id= /
Essential Questions Introduction to Sequences
Intro to Analysis of Algorithms. Algorithm “A sequence of unambiguous instructions for solving a problem, i.e., for obtaining a required output for any.
The Beauty and Joy of Computing Lecture #7 Algorithmic Complexity “Data scientists at Yahoo are using prediction markets – along with polls, sentiment.
Analyzing Programs: Order of Growth CMSC Introduction to Computer Programming October 11, 2002.
Chapter 2 Fundamentals of the Analysis of Algorithm Efficiency Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
RECURSION (CONTINUED) Lecture 9 CS2110 – Spring 2016.
FIBONACCI NUMBERS AND RECURRENCES Lecture 26 CS2110 – Spring 2016 Fibonacci (Leonardo Pisano) ? Statue in Pisa Italy.
Arithmetic and Geometric Sequences.
DIFFERENTIAL EQUATIONS
Introduction to the Design and Analysis of Algorithms
Yahoo predicts contest already!
UC Berkeley EECS Sr Lecturer SOE Dan Garcia
Fibonacci numbers and recurrences
The Beauty and Joy of Computing Lecture #4 Functions
Asymptotic Notations Algorithms perform f(n) basic operations to accomplish task Identify that function Identify size of problem (n) Count number of operations.
Simultaneous, Quadratic, Exponential and Logarithmic Equations
Fibonacci Fibonacci series 0, 1, 1, 2, 3, 5, 8, 13, 21, 34 Definition:
Fibonacci numbers Golden Ratio, recurrences
Fibonacci numbers Golden Ratio, recurrences
The Beauty and Joy of Computing Lecture #10 Recursion II
Use mathematical induction to prove that the formula is true for all natural numbers m. {image} Choose the first step of the proof from the following:
Recursion "To understand recursion, one must first understand recursion." -Stephen Hawking.
School Climate Survey 2008.
Asymptotic Notations Algorithms perform f(n) basic operations to accomplish task Identify that function Identify size of problem (n) Count number of operations.
CS201: Data Structures and Discrete Mathematics I
Rosen 5th ed., §§ ~18 slides, ~1 lecture
Functional Programming
CS 201 Fundamental Structures of Computer Science
CSE 373 Data Structures Lecture 5
Mathematical Background 2
Recursion Taken from notes by Dr. Neil Moore
Asymptotic Notations Algorithms perform f(n) basic operations to accomplish task Identify that function Identify size of problem (n) Count number of operations.
Rosen 5th ed., §§ ~18 slides, ~1 lecture
Fibonacci numbers Golden Ratio, recurrences
Discrete Mathematics 7th edition, 2009
Induction: One Step At A Time
Lawrence Snyder University of Washington
Presentation transcript:

The Beauty and Joy of Computing Lecture #10 Recursion II UC Berkeley EECS Guest TA Jon McKinsey Recursive drawing Toby Shachman created this amazing spatial programming language called “Recursive Drawing” that allows you to create drawings (even recursive ones) without typing a line of code. It’s a great example of a next-generation interface… recursivedrawing.com

How the Computer Works … n! Factorial(n) = n! Inductive definition: n! = 1 , n = 0 n! = n * (n-1)!, n > 0 Let’s act it out… “contractor” model 5! n n! 1 2 3 6 4 24 5 120

Order of growth of # of calls of n! Constant Logarithmic Linear Quadratic Exponential (source: FallingFifth.com)

How the Computer Works … fib(n) en.wikipedia.org/wiki/Fibonacci_number www.ics.uci.edu/~eppstein/161/960109.html How the Computer Works … fib(n) Inductive definition: fib(n) = n , n < 2 fib(n) = fib(n-1)+fib(n-2), n > 1 Let’s act it out… “contractor” model fib(5) n fib(n) 1 2 3 4 5 Let’s now: trace… (gif from Ybungalobill@wikimedia) Leonardo de Pisa aka, Fibonacci

Order of growth of # of calls of fib(n) Constant Logarithmic Linear Quadratic Exponential Chimney of Turku Energia, Turku, Finland featuring Fibonacci sequence in 2m high neon lights. By Italian artist Mario Merz for an environmental art project. (Wikipedia)

Counting Change (thanks to BH) Given coins {50, 25, 10, 5, 1} how many ways are there of making change? 5 2 (N, 5P) 10 4 (D, 2N, N5P, 10P) 15 6 (DN, D5P, 3N, 2N5P, 1N10P, 15P) 100?

Call Tree for “Count Change 10 (10 5 1)”  Skip Coin Use Coin  10 (10 5 1) 10 (5 1) 10 (1) 10 () 9 (1) 9 () 8 (1) 8 () 7 (1) 7 () 6 (1) 6 () 5 (1) 5 () 4 (1) 4 () 3 (1) 3 () 2 (1) 2 () 1 (1) 1 () 0 (1) 1 5 (5 1) 0 (5 1) 0 (10 5 1) D? N? D N? P? P? P? NN P? P? P? P? P? P? P? P? P? N 5P P? P? P? 10P

“I understood Count Change” Strongly disagree Disagree Neutral Agree Strongly agree img4.joyreactor.com/pics/post/drawing-recursion-girl-275624.jpeg

Menger Cube by Dan Garcia Summary It’s important to understand the machine model It’s often the cleanest, simplest way to solve many problems Esp those recursive in nature! Recursion is a very powerful idea, often separates good from great (you’re great!) Menger Cube by Dan Garcia