[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
MergeSort

(Computer science) Merge Sort

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:
1. If the input sequence has only one element, return.
2. Partition the input sequence into two halves.
3. Sort the two subsequences using the same algorithm.
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

last edited (November 2, 2006) by bilderbikkel, Number of views: 4567, Current Rev: 2 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.