Introduction and implementation of selective sorting in Java algorithm
This article mainly explains "the introduction and implementation of selection sorting in Java algorithm". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "the introduction and implementation of selection sorting in Java algorithm"!
Select sort (Selection Sort)
Brief introduction:
Selective sorting (Selection-sort) is a simple and intuitive sorting algorithm. How it works: first find the smallest (large) element in the unsorted sequence, store it at the beginning of the sorted sequence, then continue to find the smallest (largest) element from the remaining unsorted elements, and then put it at the end of the sorted sequence. And so on until all the elements are sorted.
Algorithm description:
First find the smallest (large) element in the unsorted sequence and store it at the beginning of the sorted sequence, then continue to find the smallest (large) element from the remaining unsorted elements, and then put it at the end of the sorted sequence. And so on until all the elements are sorted.
To put it simply, record a position, and then find the minimum (maximum) and put it in this position.
Java code
Public class SelectionSort {public static void main (String [] args) {int [] array = new int [] {0Arrays.toString [] array) {for (int I = 0; I) {for (int I = 0; I)
< array.length;i++){ //标记该位置的值,暂且默认为最小值 int temp = array[i]; //循环,找到最小值 for(int j = i + 1; j < array.length;j++){ if(temp >Array [j]) {temp = array [j]; array [j] = array [I]; array [I] = temp;}} array [I] = temp;} return array;}} so far, I believe you have a deeper understanding of "the introduction and implementation of selective sorting in Java algorithm". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!