-
Notifications
You must be signed in to change notification settings - Fork 48
Leaves - Emily #25
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?
Leaves - Emily #25
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 did the reverse sentence in place and did selection sort. Great job. Check out my notes and let me know if you have questions.
| while a < b do | ||
| temp = my_sentence[a] | ||
| my_sentence[a] = my_sentence[b] | ||
| my_sentence[b] = temp | ||
| a += 1 | ||
| b -=1 |
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.
Notice that you're reversing twice in this method. Could you DRY this up by creating a helper method to reverse a substring?
| # Time complexity: ? | ||
| # Space complexity: ? | ||
| # Time complexity: O(n^2), n == number of words in the sentence | ||
| # Space complexity: 1 |
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.
Technically space complexity is O(n) because you are doing a .split.
| # Space complexity: ? | ||
| # Time complexity: O(n^2), n == number of words in the sentence | ||
| # Space complexity: 1 | ||
| 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.
Nicely done selection sort.
Sorting & Reverse Sentence