-
Notifications
You must be signed in to change notification settings - Fork 53
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
# 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
# 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
# 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
# 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
# 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Very compact!
# 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
# 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
# Time complexity: O(log n) | ||
# Space complexity: O(log n) | ||
def digit_match(n, m) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
# 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) |
There was a problem hiding this comment.
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)
No description provided.