ShmoopTube

Where Monty Python meets your 10th grade teacher.

Search Thousands of Shmoop Videos


Computer Science Videos 112 videos

Computer Science: Setting Up Your Environment
19 Views

Just as you move your furniture into a new house before spending the night, you’ve got to spend a little time setting up your environment when yo...

Computer Science: Doubles and Ints
17 Views

Doubles and ints. At first glance, it may look like this video will be about baseball and football statistics. But they're actually computer scienc...

AP Computer Science 1.1 Classes and Objects
468 Views

AP Computer Science: Classes and Objects Drill 1, Problem 1. Which of the following is a correct {/* Implementation */} for the isInsect method?

See All

AP Computer Science 1.2 Standard Algorithms 172 Views


Share It!


Description:

AP Computer Science 1.2 Standard Algorithms. What is the output of Recurse(5)?


Transcript

00:00

Thank you We sneak here's your shmoop du jour featuring

00:05

a function called re curse Previously on lee used by

00:09

ancient mummies with all right Well what is the output

00:13

of re curse five i'm thinking we're thinking they're your

00:17

potential answers All right Uh thank And let's Go boy

00:23

don't be deceived This little recursive function looks simple but

00:26

noticed here that unless the imager an equal zero it's

00:29

going to do a little math on whatever imager was

00:31

given in call itself again And as long as n

00:35

is a non zero value this function will keep calling

00:38

itself over and over and over and over again You're

00:40

done If an equal zero return one All right That

00:45

peace is important It's the rikers in loops based case

00:49

The condition that must be met to put an end

00:51

to this madness No zero on then It's not over

00:55

Right Well when we finally do get into equal zero

00:58

the function will return a one The question asked us

01:02

to consider end to be five Well being that five

01:05

is not equal to zero We instead move allowed to

01:08

one plus two times recursive Five minutes to five minutes

01:12

To three So now we're going back over the function

01:14

with a three instead of a five Well guess what

01:17

three is also not equals Zero so we're looking at

01:20

one plus two times recursive three months two three minus

01:22

two is one and again top one is not zero

01:25

one plus two times recursive one minus two but one

01:28

minus two is negative one in california Anyway negative one

01:31

is not zero one plus two times workers of negative

01:34

one negative too well negative one minus two is negative

01:38

three and we can see where this is going on

01:41

a downward spiral that will never crawl out of because

01:44

we've skipped zero entirely and we'll never get in back

01:48

up to meet the bass case So the answer is 00:01:50.313 --> [endTime] e for ever Never never Oh

Related Videos

AP Computer Science 1.2 GridWorld Case Study and APIs
493 Views

AP Computer Science 1.2 GridWorld Case Study and APIs. What is the direction of the actor?

AP Computer Science 1.4 Standard Algorithms
200 Views

AP Computer Science 1.4 Standard Algorithms. How many times will mystery be called for mystery(n) for n > 1?

AP Computer Science 2.3 Classes and Objects
191 Views

AP Computer Science 2.3 Classes and Objects. Which of the following is correct implementation of the Country class?

AP Computer Science 3.4 Inheritance, Abstraction, and Polymorphism
204 Views

AP Computer Science 3.4 Inheritance, Abstraction, and Polymorphism. Which of the following will satisfy the conditional if statement for boo, str,...

AP Computer Science 4.2 Standard Algorithms
191 Views

AP Computer Science 4.2 Standard Algorithms. What kind of algorithm is the following?