2.2 Flashcards
What are the three steps in a merge sort
Divide, Conquer, Merge
What does the divide section of a merge sort do
Splits each item in the array into their individual subarrays
What does the conquer section of a merge sort do
Each subarray is sorted individually by comparing each subarray with the next subarray
What does the merge section of a merge sort do
The sorted subarrays are merged back together in sorted order, this is repeated until all subarrays have been merged
How does a bubble sort work
Compare the current item with the next item in the array, swapping if necessary until a swap cant be made, if a swap cant be made the “current item” is the item that cant be swapped against, this process continues until the end of the array has been reached where it starts again from the beginning, this process continues until no swaps have been made where the process terminates and the list has been sorted.
Insertion sort stars at the second element in the input, and compares it to the element to its left. If the two elements are in the wrong order, the smaller element is placed in the
lowest position. The third element in the input is then selected. It is inserted into the correct position in the sorted portion of the input to its left. This continues until the last element is
inserted into the correct position, resulting in a fully sorted array.