Shortcut for chapter specific information

Wednesday, April 20, 2011

More about insertion sort

From Wikipedia, learned couple of more things about insertion sort.
1, It is stable.  That is the key with the same value will not change its order.  (Consider line 4 second comparison, what if two values are the same?)
2, It is adaptive. You just need to understand the best case scenario to get a feeling of it.  I don't want to get into the math though. (Since I don't know.)
3, Other than the form I saw in TCRC, there is also a sentinel form of the algorithm.   Always look for a different form of the algorithm.   Some people will call that form as "straight insertion sort".

33_P

No comments:

Post a Comment