Refer: Main indexed article on sorting.
Selection sort is a simple algorithm.
It divides the input lists into two parts:
Initially the sorted sub-list is empty and the unsorted sub-list is the entire input list.
The algorithm proceeds by finding the smallest (or largest depending on the sorting order) element in the unsorted sub-list exchanging it with the leftmost unsorted element (putting in sorted order) and moving the sub-list boundaries one element to the right.
Selection sort is a simple algorithm.
It divides the input lists into two parts:
- The sub-list of the items are already sorted, which is built up from left to right at the front(left) of the list
- The sub-list of the items remaining to be sorted that occupy the rest of the list.
Initially the sorted sub-list is empty and the unsorted sub-list is the entire input list.
The algorithm proceeds by finding the smallest (or largest depending on the sorting order) element in the unsorted sub-list exchanging it with the leftmost unsorted element (putting in sorted order) and moving the sub-list boundaries one element to the right.
Java code snippet:
No comments:
Post a Comment