-
Notifications
You must be signed in to change notification settings - Fork 48
Sara-Branches #33
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?
Sara-Branches #33
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 all the learning goals here. Check out my comments and let me know if you have questions. Well done!
|
|
||
| end | ||
|
|
||
| def reverse(sentence, i, j) |
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 love the helper method
| # A method to reverse the words in a sentence, in place. | ||
| # Time complexity: ? | ||
| # Space complexity: ? | ||
| # Time complexity: o(n^2) |
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), since you don't reverse the string n times, but only smaller words. If you want to be technical it's O(n * m) where m is the length of a word, but since most words are pretty small you can drop that term.
| # Time complexity: o(n^2) | ||
| # Space complexity: o(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.
Correct
| # Time complexity: o(n^2) | ||
| # Space complexity: o(n) | ||
|
|
||
| def sort_by_length(my_sentence) |
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 bubblesort.
Sorting & Reverse Sentence