Download presentation

Presentation is loading. Please wait.

Published byDarryl Scarff Modified over 2 years ago

1
Tree Recursion Traditional Approach

2
Tree Recursion Consider the Fibonacci Number Sequence: Time: , 1, 1, 2, 3, 5, 8, 13, 21,... / 0when n = 0 fib(n) = | 1when n = 1 \ fib(n - 1) + fib(n - 2)otherwise

3
Tree Recursion (cont.) As code this is: int fib ( int n ) { if ( n <= 0 ) return 0; else if ( n = 1 ) return 1; else return fib ( n - 1 ) + fib ( n - 2 ) ; }

4
What happens when computing fib(5)? fib(5) int fib ( int n ) { if ( n <= 0 ) return 0; else if ( n = 1 ) return 1; else return fib ( n - 1 ) + fib ( n - 2 ) ; }

5
fib(5) fib(4) fib(3) What happens when computing fib(5)? int fib ( int n ) { if ( n <= 0 ) return 0; else if ( n = 1 ) return 1; else return fib ( n - 1 ) + fib ( n - 2 ) ; }

6
fib(5) fib(4) fib(3) What happens when computing fib(5)? int fib ( int n ) { if ( n <= 0 ) return 0; else if ( n = 1 ) return 1; else return fib ( n - 1 ) + fib ( n - 2 ) ; }

7
fib(5) fib(4) fib(3) fib(2) What happens when computing fib(5)? int fib ( int n ) { if ( n <= 0 ) return 0; else if ( n = 1 ) return 1; else return fib ( n - 1 ) + fib ( n - 2 ) ; }

8
fib(5) fib(4) fib(3) fib(2) What happens when computing fib(5)? int fib ( int n ) { if ( n <= 0 ) return 0; else if ( n = 1 ) return 1; else return fib ( n - 1 ) + fib ( n - 2 ) ; }

9
fib(5) fib(4) fib(3) fib(2) fib(1) What happens when computing fib(5)? int fib ( int n ) { if ( n <= 0 ) return 0; else if ( n = 1 ) return 1; else return fib ( n - 1 ) + fib ( n - 2 ) ; }

10
fib(5) fib(4) fib(3) fib(2) fib(1) What happens when computing fib(5)? int fib ( int n ) { if ( n <= 0 ) return 0; else if ( n = 1 ) return 1; else return fib ( n - 1 ) + fib ( n - 2 ) ; }

11
What happens when computing fib(5)?

12
What is the Problem? I am explaining everything! Why not make this more interesting by using MS Agents Agents are helpers like the paper clip in Word But they are much more: They talk to you And can, in some cases, understand voice commands

13
Tree Recursion MS Agent Approach

14
Tree Recursion Consider the Fibonacci Number Sequence: Time: , 1, 1, 2, 3, 5, 8, 13, 21,... This sequence is defined by the rule: / 0when n = 0 fib(n) = | 1when n = 1 \ fib(n - 1) + fib(n - 2)otherwise

15
Tree Recursion (cont.) As code this is: int fib ( int n ) { if ( n <= 0 ) return 0; else if ( n = 1 ) return 1; else return fib ( n - 1 ) + fib ( n - 2 ) ; }

16
What happens when computing fib(5)? fib(5) int fib ( int n ) { if ( n <= 0 ) return 0; else if ( n = 1 ) return 1; else return fib ( n - 1 ) + fib ( n - 2 ) ; }

17
fib(5) fib(4) fib(3) What happens when computing fib(5)? int fib ( int n ) { if ( n <= 0 ) return 0; else if ( n = 1 ) return 1; else return fib ( n - 1 ) + fib ( n - 2 ) ; }

18
fib(5) fib(4) fib(3) What happens when computing fib(5)? int fib ( int n ) { if ( n <= 0 ) return 0; else if ( n = 1 ) return 1; else return fib ( n - 1 ) + fib ( n - 2 ) ; }

19
fib(5) fib(4) fib(3) fib(2) What happens when computing fib(5)? int fib ( int n ) { if ( n <= 0 ) return 0; else if ( n = 1 ) return 1; else return fib ( n - 1 ) + fib ( n - 2 ) ; }

20
fib(5) fib(4) fib(3) fib(2) What happens when computing fib(5)? int fib ( int n ) { if ( n <= 0 ) return 0; else if ( n = 1 ) return 1; else return fib ( n - 1 ) + fib ( n - 2 ) ; }

21
fib(5) fib(4) fib(3) fib(2) fib(1) What happens when computing fib(5)? int fib ( int n ) { if ( n <= 0 ) return 0; else if ( n = 1 ) return 1; else return fib ( n - 1 ) + fib ( n - 2 ) ; }

22
MASH: Microsoft Agent Scripting Helper MASH is an editor that allows you to construct the scripts that you can then embed in other applications MASH

23
Where to Learn More MS Agent Page: Sunfires MS Agent Page: Uniquities MS Agent Planet: Presentation Narrator: Microsoft Agent Scripting Helper:

Similar presentations

© 2016 SlidePlayer.com Inc.

All rights reserved.

Ads by Google