Sorting Algorithms Flashcards
(6 cards)
What is Bubble Sort?
compares two items at a time and swaps them if they are in the wrong order. It repeats this until the whole list is sorted It goes through the list many times, each time moving the biggest unsorted item to the end
What is Merge Sort?
It keeps splitting the list in half until each piece has one item, then puts the pieces back together in the right order.
What is Insertion Sort?
Insertion Sort builds a sorted list one item at a time by inserting each new item into the right place.
Which is the fastest
Merge Sort is usually the fastest because it splits the list and works on parts at the same time.
Which sorting algorithm is the simplest?
Bubble Sort is the simplest to understand, but it’s also the slowest for large lists.
When is Insertion Sort useful?
Insertion Sort is good for small lists or when the list is almost sorted already.