Presentation is loading. Please wait.

Presentation is loading. Please wait.

Straight Selection Sort

Similar presentations


Presentation on theme: "Straight Selection Sort"— Presentation transcript:

1 Straight Selection Sort
values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] Divides the array into two parts: already sorted, and not yet sorted. On each pass, finds the smallest of the unsorted elements, and swaps it into its correct place, thereby increasing the number of sorted elements by one. 36 24 10 6 12

2 Selection Sort: Pass One
values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] 36 24 10 6 12 U N S O R T E D

3 Selection Sort: End Pass One
values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] SORTED 6 24 10 36 12 U N S O R T E D

4 Selection Sort: Pass Two
values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] SORTED 6 24 10 36 12 U N S O R T E D

5 Selection Sort: End Pass Two
values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] SORTED 6 10 24 36 12 U N S O R T E D

6 Selection Sort: Pass Three
values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] SORTED 6 10 24 36 12 U N S O R T E D

7 Selection Sort: End Pass Three
values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] 6 10 12 36 24 S O R T E D UNSORTED

8 Selection Sort: Pass Four
values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] 6 10 12 36 24 S O R T E D UNSORTED

9 Selection Sort: End Pass Four
values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] 6 10 12 24 36 S O R T E D


Download ppt "Straight Selection Sort"

Similar presentations


Ads by Google