Explain Merge Sorting With Example.
Merge Sort does essentially everything we would like a sorting algorithm to do:
It runs in O(n log n) time.
It is stable.
It works well with various data structures (especially linked lists).
Thus, Merge Sort is a good standard by which to judge sorting algorithms.
When considering some other sorting algorithm, ask:
How is this algorithm better than Merge Sort?
If it is not better in any way, then use Merge Sort?
How is this algorithm worse than Merge Sort?
If it is better than Merge Sort in some way, then it must also be worse in some way.
In the application being considered, are the advantages worth the disadvantages?
Labels: Data Structure