Skip to content

Water - Sophia#43

Open
SoCodeDo wants to merge 10 commits into
Ada-C14:masterfrom
SoCodeDo:master
Open

Water - Sophia#43
SoCodeDo wants to merge 10 commits into
Ada-C14:masterfrom
SoCodeDo:master

Conversation

@SoCodeDo
Copy link
Copy Markdown

@SoCodeDo SoCodeDo commented Nov 9, 2020

Chris, I wasn't sure on how to do start the final one, but wanted to get this in. I will try to re-attempt this week. Thanks!

Copy link
Copy Markdown

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

Thanks for getting in what you did. Not bad, you had the methods right, just look at my feedback regarding the time/space complexity.

Comment thread lib/recursive-methods.rb
Comment on lines +3 to 5
# Time complexity: O(n)
# Space complexity: O(n)
def factorial(n)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread lib/recursive-methods.rb
Comment on lines +15 to 17
# Time complexity: O(n)
# Space complexity: O(n)
def reverse(s)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍 However the space & time complexity are O(n^2) because the slice you do has space/time complexity of O(n)

Comment thread lib/recursive-methods.rb
Comment on lines +25 to 27
# # Time complexity: O(1)
# # Space complexity: O(1)
def reverse_inplace(s)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ How could you reverse an entire string in O(1) time?

Also you're using the exact method I told you not to use.

Comment thread lib/recursive-methods.rb
Comment on lines +35 to -24
# # Time complexity: O(n)
# # Space complexity: O(n)
def bunny(n)
raise NotImplementedError, "Method not implemented"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread lib/recursive-methods.rb
Comment on lines +45 to 47
# # Time complexity: O(n^2) * not sure about this one
# # Space complexity: O(n^2) * same here?
def nested(s)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍 Correct!

Comment thread lib/recursive-methods.rb
Comment on lines +58 to 60
# # Time complexity: O(n)
# # Space complexity: O(n^2)
def search(array, value)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This works, but once again the time complexity is O(n^2)

Comment thread lib/recursive-methods.rb
Comment on lines +71 to 73
# # Time complexity: O(n)
# # Space complexity: O(n)
def is_palindrome(s)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This works, but once again the time complexity is O(n^2)

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