| Free tutorials for Java, Eclipse and Web programming |
Version 1.1
Copyright © 2009 - 2011 Lars Vogel
08.02.2011
| Revision History | ||
|---|---|---|
| Revision 0.1 | 17.05.2009 | Lars Vogel |
| Created | ||
| Revision 0.2 - 1.1 | 06.09.2009 - 2011 | Lars Vogel |
| bugfixes and enhancements | ||
Table of Contents
Mergesort is a divide and conquer algorithm. The sorting elements are stored in a collection. This collection is divided into two collections and these are again sorted via mergesort. Once the two collections are sorted then the result is combined
Mergesort will take the middle of the collection and takes then the two collection for the next iteration of mergesort. In the merging part mergesort runs through the both collections and selects the lowest of the both to insert it into a new collection.
In comparison to quicksort the divide part is simple in mergesort while the merging take is complex. In addition quicksort can work "inline", e.g. it does not have to create a copy of the collection while mergesort requires a copy.