Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

The selection sort algorithm


Published on

Simon Watson & Jonathan Holmes

Published in: Technology
  • Login to see the comments

  • Be the first to like this

The selection sort algorithm

  1. 1. The Selection Sort Algorithm Logic and Design II Simon Watson & Jonathan Holmes
  2. 2. CONCEPT The selection sort is a sorting algorithm that is much more efficient than the bubble sort. The selection sort algorithm steps through an array, moving each value to its final sorted position.
  3. 3.  The selection sort algorithm usually performs fewer swaps because it moves items immediately to their final position in the array.  The selection sort works like this: The smallest value in the array Is located and moved to element 0. Then, the next smallest value is located and moved to element 1. This process continues until all of the elements have been placed in their proper order.
  4. 4. Examples 5 7 2 8 9 1 The selection sort scans the array, starting at element 0, and locates the element with the smallest value. Then, the contents of this element are swapped with the contents of element 0. In this example, the 1 stored in element 5 is swapped with the 5 stored in element 0.
  5. 5. Examples 1 7 2 8 9 5 Array after swapping elements