Sorting --- Merge Sort

Steven J. Zeil

Old Dominion University, Dept. of Computer Science

Table of Contents

1. Merging Sorted Data
1.1. Understanding the Merge Algorithm
1.2. Merge Analysis
2. Merge Sort
2.1. The Algorithm
2.2. MergeSort Analysis

Our next algorithm actually achieves the optimal big-O behavior for a sorting algorithm. The Merge sort has O(n log n) time for both its worst and average case.

This doesn't necessarily make it the ideal choice, however, in all sorting applications. The constant multiplier on the timing is somewhat high, and Merge sort may require an unusually high amount of memory.

Variants of the basic Merge sort algorityhm are, however, often used with linked lists (which can't be sorted by most other O(n log n) algorithms and are used to sort data residing on disk or magnetic tape.

In the Forum:

(no threads at this time)