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

Sockets - Cyndi #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Sockets - Cyndi #18

wants to merge 2 commits into from

Conversation

cyndilopez
Copy link

No description provided.

Copy link

@eric-andeen eric-andeen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks pretty good, but your solution has exponential time complexity. Fibonacci can be calculated in linear time with either an iterative or a recursive approach, which is obviously way better than exponential.

You should rewrite this to find a linear-time solution.

# Time complexity: ?
# Space complexity: ?
# n is the input number
# Time complexity: O(2n), since 2n steps will be needed.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect. Each function call generates two additional function calls, so time complexity is really O(2^n).

if n == 0
return 0
elsif n == 1
# p "n = 1"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a useful comment. Remove.

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