Selection vs Insertion Sort

Continuation of previous post…

For semi sorted data, Insertion sort is a lot faster than selection sort.  Insertion sort can sort of tell that’s it’s sorted so there is not as much swapping necessary. Selection sort still does all the comparisons regardless of random or semi sorted data.

Tradeoff: Cost of comparison vs cost of swapping.

Advertisements
This entry was posted in Coding and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s