Showing posts with label Selection. Show all posts
Showing posts with label Selection. Show all posts

Monday, 19 December 2011

Brief idea about Sorting

Five basic kinds of sorting algorithms are available to the programmer:

  • Insertion sorts

  • Exchange sorts

  • Selection sorts

  • Merge sorts

  • Distribution sorts


An easy way to visualize how each sorting algorithm works is to think about how to sort a shuffled deck of cards lying on the table using each method. The cards are to be sorted by suit (clubs, diamonds, hearts, and spades) as well as by rank (2 through ace). You might have seen some of these algorithms in action at your last bridge game.

In an insertion sort, you pick up the cards one at a time, starting with the top card in the pile, and insert them into the correct position in