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

Recursion-writing Gessica Mohr #29

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

Conversation

GeMath18
Copy link

@GeMath18 GeMath18 commented Nov 3, 2020

No description provided.

Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

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

Nice work Gessica, you hit the learning goals here. Well done.

@@ -0,0 +1,6 @@
# Default ignored files

Choose a reason for hiding this comment

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

I suggest you add .idea to your .gitignore or .gitignore_global files.

Comment on lines +3 to 5
# Time complexity: O(n) it depends on the size of n to run
# Space complexity: O(n) it creates a stack every time it calls the recursive method
def factorial(n)

Choose a reason for hiding this comment

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

👍

Comment on lines +12 to 14
# Time complexity: O(n^2) - the slice method in the reverse method creates another array so that counts for O(n) and then the method runs n times depending on the size of array, O(n). Total of O(n^2).
# Space complexity: O(n^2) - because we are creating a new array when using the slice method and it creates a stack to run the recursion method.
def reverse(s)

Choose a reason for hiding this comment

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

👍

Comment on lines +23 to +25
# Time complexity: O(n) it depends on the size of s to run
# Space complexity: O(n) it creates a stack every time if calls the recursive method
def reverse_inplace(s, i = 0, j = s.length - 1)

Choose a reason for hiding this comment

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

👍

Comment on lines +36 to 38
# Time complexity: O(n) it depends on the size of n to run
# Space complexity: O(n) it creates a stack every time if calls the recursive method
def bunny(n)

Choose a reason for hiding this comment

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

👍

Comment on lines +43 to +45
# Time complexity: O(n) it depends on the size of s to run
# Space complexity: O(n) it creates a stack every time if calls the recursive method
def nested(s, i = 0, j = s.length - 1)

Choose a reason for hiding this comment

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

👍 Very compact!

Comment on lines +52 to +54
# Time complexity: O(n) it depends on the size of the array to run
# Space complexity: O(n) it creates a stack every time if calls the recursive method
def search(array, value, index = 0)

Choose a reason for hiding this comment

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

👍

Comment on lines +60 to +62
# Time complexity: O(n) it depends on the size of s to run
# Space complexity: O(n) it creates a stack every time if calls the recursive method
def is_palindrome(s, i = 0, j = s.length - 1)

Choose a reason for hiding this comment

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

👍

Comment on lines +69 to 71
# Time complexity: O(log n)
# Space complexity: O(log n)
def digit_match(n, m)

Choose a reason for hiding this comment

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

👍

Comment on lines +85 to +87
# Time complexity: O(2^n) it depends on the size of n to run
# Space complexity: O(2^n) it creates a stack every time if calls the recursive method
def fibonacci(n)

Choose a reason for hiding this comment

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

👍 However the space complexity is O(n)

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