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

Ida - Fire - Recursive Writing #35

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

Conversation

idago123
Copy link

@idago123 idago123 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.

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

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)
# Space complexity: O(n)
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 +11 to 13
# Time complexity: O(n)
# Space complexity: O(n)
def reverse(s)

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.

Comment on lines +21 to 23
# Time complexity: O(n)
# Space complexity: 0(n)
def reverse_inplace(s)

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

Suggested change
# 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)

Comment on lines +30 to 32
# Time complexity: o(n)
# Space complexity: o(n)
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 +40 to 42
# Time complexity: o(n)
# Space complexity: o(n)
def nested(s)

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.

Comment on lines +52 to 54
# Time complexity: o(n)
# Space complexity: o(n)
def search(array, value)

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.

Comment on lines +60 to 62
# Time complexity: o(n)
# Space complexity: o(n)
def is_palindrome(s)

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.

Comment on lines +72 to 74
# Time complexity: o(n)
# Space complexity: o(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.

👍 Similar issues on time/space complexity.

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