ShmoopTube
Where Monty Python meets your 10th grade teacher.
Search Thousands of Shmoop Videos
Standard Algorithms Videos 19 videos
APCS: Standard Algorithms Drill 2, Problem 1. How much slower is InefficientSum than EfficientSum in the best case for an array of n elements?
In this computer science drill question, figure out which implementation will copy one array over to another.
AP Computer Science: Standard Algorithms Drill 3, Problem 3. What should go in "expression 1" to satisfy the conditional statement?
AP Computer Science 1.4 Standard Algorithms 200 Views
Share It!
Description:
AP Computer Science 1.4 Standard Algorithms. How many times will mystery be called for mystery(n) for n > 1?
Transcript
- 00:00
Hurry And here's your shmoop too sure brought to you
- 00:05
by fibonacci sequins mathematicians bling dream Consider the following code
- 00:11
segments public All right how many times will mystery be
- 00:15
called for a mystery And for n is greater than
- 00:18
one including the initial call Fibonacci n returns the fibonacci
Full Transcript
- 00:22
number Shmoop Well easiest way to go about this is
- 00:28
the plug numbers into the method Let's start with one
- 00:32
We plug one into mystery The method immediately returns giving
- 00:35
us one call The initial call if we next plug
- 00:38
in to the method immediately returns totaling one call Plugging
- 00:43
three gets a little more complicated method then executes mystery
- 00:47
with a parameter of two And again with a parameter
- 00:50
of one But this gives us three total calls All
- 00:54
right So let's test with one more number If we
- 00:56
plug in for the method makes a call to mystery
- 00:58
with a parameter of three which gives us three calls
- 01:00
in total and with parameter to which gives us one
- 01:03
call in total But adding those up along with the
- 01:06
initial call we have five calls let's See what our
- 01:08
sequence looks like so far All right Well this seems
- 01:11
like a familiar sequence We all know knowing that our
- 01:14
answer probably involves the fibonacci numbers We can narrow our
- 01:18
choices down to c and d and now we can
- 01:20
compare the two Well if choice d was the correct
- 01:23
answer we have the following sequence that evaluates to three
- 01:26
three five Seven Well that doesn't look like our sequence
- 01:29
so we know our answer must be c but let's
- 01:32
check to be sure Plugging in Numbers 1 through 4
- 01:34
It gives us the following sequence Yeah and that's equal
- 01:39
to one one three five and yeah that's the same
- 01:42
as our original sequence So choice sees our answer You
- 01:45
know we really wish we could offer you some of 00:01:47.563 --> [endTime] these delicious nachos Once you start you can't stop
Related Videos
AP Computer Science 1.2 GridWorld Case Study and APIs. What is the direction of the actor?
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. Which of the following will satisfy the conditional if statement for boo, str,...
AP Computer Science 4.2 Standard Algorithms. What kind of algorithm is the following?
AP Computer Science 4.4 Classes and Objects. What is the return type of a mutator method?