-
Notifications
You must be signed in to change notification settings - Fork 39
Sockets - Sarah #1
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
base: master
Are you sure you want to change the base?
Conversation
CheezItMan
left a comment
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, you hit the learning goals here. See my comments regarding space and time as you missed the cost of some of the built-in ruby methods.
Overall, outstanding work
|
|
||
| # Time complexity: ? | ||
| # Space complexity: ? | ||
| # Time complexity: O(n), where n is the length of s, reverse will get called n/2 times |
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 is actually O(n^2) since s[1...-1] creates a new string of length n-2 each iteration. This is true for both space & time.
|
|
||
| # Time complexity: O(n), where n is the length of s, reverse will get called n/2 times | ||
| # Space complexity: O(n) where n is the length of s, n/2 number of stack frames will be used. Unless you are using a language that utilizes tail recursion, then the space complexity would be constant | ||
| def r_reverse_inplace(s, i) |
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.
👍 Outstanding
| # Time complexity: ? | ||
| # Space complexity: ? | ||
| # Time complexity: O(n), where n is the length of s, nested will get called n/2 times | ||
| # Space complexity: O(n) where n is the length of s. A new stack frame will be used each call, and by slicing into the array a new array is created during each call, which i think would make it 0(2n) |
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.
O(n^2) similar to reverse.
| # 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.
O(n^2) similar to reverse.
| # Space complexity: ? | ||
| # Time complexity: O(n), where n is the length of s, nested will get called n/2 times | ||
| # Space complexity: O(n) where n is the length of s. A new stack frame will be used each call | ||
| 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.
O(n^2) similar to reverse.
Could you have used a technique similar to the one you used with reverse_in_place?
| return is_palindrome(s.slice!(1...-1)) | ||
| end | ||
|
|
||
| # Time complexity: O(log10 n) where n is the smaller number between n and m, each call to r_didget_match divids both numbres by 10 and terminates when wither becomes 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.
👍
No description provided.