Merge Sort: A Brief Look at One of The Earlier Sorting Algorithms
Merge Sort: A Brief Look at One of The Earlier Sorting Algorithms
Here we have the months of the year, except somehow they were placed
out of order
Compare again
The first item in the first two groups are
compared and the earlier month is added to the
new set
Round 2
and then the second item in the first group
is compared with the first item of the second
group
And sorted
Sort complete!
Class Demonstrati0n
Get eight volunteers to stand in a line at the front of
the classroom
Have each draw a number out of a hat
Perform a merge sort on the volunteers by
comparing their numbers and grouping accordingly
Alternatively, use height for sorting if that can be
done without hurting morale
Time Complexity
Best case: O(n)
Memory Requirements
Array implementation
References
http
://www.cprogramming.com/tutorial/computerscienc
etheory/
mergesort.html
http://www.sorting-algorithms.com/merge-sort
http://www.personal.kent.edu/~rmuhamma/Algori
thms/MyAlgorithms/Sorting/
mergeSort.htm
http://en.wikipedia.org/wiki/Merge_sort