Skip to content

Conversation

@morganschuler
Copy link

Sorting & Reverse Sentence

Question Answer
Describe how Bubble Sort works Bubble sort works by repeatedly swapping the adjacent elements if they are in wrong order
Describe how Selection Sort works As perfectly stated on wikipedia: The algorithm divides the input list into two parts: the sublist of items already sorted, which is built up from left to right at the front (left) of the list, and the sublist of items remaining to be sorted that occupy the rest of the list. Initially, the sorted sublist is empty and the unsorted sublist is the entire input list. The algorithm proceeds by finding the smallest (or largest, depending on sorting order) element in the unsorted sublist, exchanging (swapping) it with the leftmost unsorted element (putting it in sorted order), and moving the sublist boundaries one element to the right.
Describe how Insertion sort works The insertion sort inserts the values in a presorted file to sort a set of values. This differs from selection sort because the selection sort finds the minimum number from the list and sort it in some order.
Which Sorting Algorithm has the best time complexity? This would depend on scaleability, but generally bubble and insertion sort have the best time complexities.
 

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.

Nice work with reverse words. Take a look at my comments and let me know if you have any questions. You also have a working sort. Great work!

@@ -1,6 +1,37 @@
def reverse_sentence_from_start_to_end(my_sentence, start_index, end_index)

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.

raise NotImplementedError, "Method not implemented"
end
words = my_sentence.split(" ")
results = []

Choose a reason for hiding this comment

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

Why make this other array? Why not swap elements inside words?

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