Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fibonacci - Danielle #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fibonacci - Danielle #16

wants to merge 1 commit into from

Conversation

danimetz
Copy link

@danimetz danimetz commented Oct 8, 2018

No description provided.

@shrutivanw
Copy link

Nice work thinking about this recursively. It turns out that the space complexity of the recursive approach to fibonacci, like in your algorithm results in a time complexity of O(2^n). You already know that exponential is one of the worst time complexity. Also, the space complexity of this algorithm will be O(n) due to the call stack space it uses.

With that in mind, can you think of an algorithm to approach this iteratively instead of recursively? The iterative approach will have better time and space complexity than your current recursive algorithm, and is hence a more efficient solution. Once you have given it some thought, compare your iterative solution with https://github.com/Ada-C10/fibonacci/blob/solution/lib/fibonacci.rb

We will be looking at this recursive approach to fibonacci later in class. Feel free to take a look at the later slides in https://drive.google.com/file/d/0B__DV26QHsH4bWJmS1A0QXBad1U/view?usp=sharing if you're curious. (P.S: play the slide show in Google slides so you can see the animations)

Slack me if you'd like to discuss further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants