[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
MergeSort
Displaying differences between revision 1 and the latest revision
= ([b[ComputerScience | Computer science]]) Merge Sort[/b] =
This is where two items are sorted, then another two items. Next, those total four items are ordered. The process continues again until the next four are sorted, then those first eight are then sorted. The pattern continues until everything is sorted.
Algorithm:[br]
1. If the input sequence has only one element, return.[br]
2. Partition the input sequence into two halves.[br]
3. Sort the two subsequences using the same algorithm.[br]
4. Merge the two sorted subsequences to form the output sequence.
Here's a Java animation if you need some help visualizing this: http://www2.ics.hawaii.edu/~qizhang/ics665/mergesort.html
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
MergeSort
Displaying differences between revision 1 and the latest revision
= ([
This is where two items are sorted, then another two items. Next, those total four items are ordered. The process continues again until the next four are sorted, then those first eight are then sorted. The pattern continues until everything is sorted.
Algorithm:[br]
1. If the input sequence has only one element, return.[br]
2. Partition the input sequence into two halves.[br]
3. Sort the two subsequences using the same algorithm.[br]
4. Merge the two sorted subsequences to form the output sequence.
Here's a Java animation if you need some help visualizing this: http://www2.ics.hawaii.edu/~qizhang/ics665/mergesort.html
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
