source :
http://mathbits.com/MathBits/Java/arrays/SelectionSort.htm
Array at beginning: | 84 | 69 | 76 | 86 | 94 | 91 |
After Pass #1: | 84 | 91 | 76 | 86 | 94 | 69 |
After Pass #2: | 84 | 91 | 94 | 86 | 76 | 69 |
After Pass #3: | 86 | 91 | 94 | 84 | 76 | 69 |
After Pass #4: | 94 | 91 | 86 | 84 | 76 | 69 |
After Pass #5 (done): | 94 | 91 | 86 | 84 | 76 | 69 |
While being an easy sort to program, the selection sort is one of the least efficient. The algorithm offers no way to end the sort early, even if it begins with an already sorted list.
// Selection Sort Method for Descending Orderpublic static void SelectionSort ( int [ ] num )
|
沒有留言:
張貼留言