Selection Sort:
Print this page
 
  • As we have discussed earlier, purpose of sorting is to arrange a given set of records in order by specified key. In  the case of student records, key can be roll number. In the case of employees records, key can be employ  identification number. That is, sorting a set of records based on specific key.
  • Insertion and Sink sorts compare keys of two records and swap them if the keys are not in order. This is not just      swapping keys, we have to swap whole records associated with those keys.
  • The time required to swap records is proportional to its size, that is number of fields.
  • In these methods, same record may be swapped many times, before reaching its final position in sorted order.
  • This method, selection sort, minimized the number of swaps. Hence efficient if the size of the records are large.
  • Look at keys of all records to find a record with smallest key and place the record in the first place.
  • Next, find the smallest key record among remaining records and swap with the record at second position.
  • Continue this procedure till all records are placed correctly.

                                                                                                         An Applet Demonstration of Selection Sort

 

 
Prev