-
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
Ida - Fire - Recursive Writing #35
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.
Overall nice work Ida. You have working methods here, but there are some issues here with time/space complexity. Take a look at my comments and let me know what questions you have.
@@ -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) | ||
# Space complexity: O(n) | ||
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) | ||
# Space complexity: O(n) | ||
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.
👍 , however this is O(n^2) because you are doing the same as the slice method with each recursive call.
# Time complexity: O(n) | ||
# Space complexity: 0(n) | ||
def reverse_inplace(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.
This works, but it is not in place and essentially the same as the previous method.
Think about if you adjusted the method signature as follows
# Time complexity: O(n) | |
# Space complexity: 0(n) | |
def reverse_inplace(s) | |
# Time complexity: O(n) | |
# Space complexity: 0(n) | |
def reverse_inplace(s, low = 0, high = s.length - 1) |
# Time complexity: o(n) | ||
# Space complexity: o(n) | ||
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) | ||
# Space complexity: o(n) | ||
def nested(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.
👍 However because you have a slice with each recursive call, this is O(n^2) for both time and space complexity.
# Time complexity: o(n) | ||
# Space complexity: o(n) | ||
def search(array, value) |
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 due to the slice you have O(n^2) for time and space complexity.
# Time complexity: o(n) | ||
# Space complexity: o(n) | ||
def is_palindrome(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.
👍 Similar issues to the above with time and space complexity.
# Time complexity: o(n) | ||
# Space complexity: o(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.
👍 Similar issues on time/space complexity.
No description provided.