Shortcut for chapter specific information

Wednesday, April 27, 2011

Merge sort

I decided to start thinking of how to write a respectable merge sort.  Compare to insertion and selection.  Basic merge sort requires significantly more skill.  Obviously to practice it like what I have been doing with insertion and selection.  (In case, you hadn't figured out yet - I always try to write a program mistake free in one-shot.)

The key part is merge.  The standard algorithm requires used of auxillary memory as well as sentinel.   Also, as one might know by reading, insertion sort is usually being used when the size of array is less than 10.   This is important to know.  If you were like me, you would probably doubt that it is necessary.  Of course, both of them are not necessary component of sorting.  You can write an in-place algorithm without a sentinel as well. 

No comments:

Post a Comment