1、优化之前 /*** @BelongsProject: demo* @BelongsPackage: com.wzl.Algorithm.DirectSelectionSort* @Author: Wuzilong* @Description: 选择排序* @CreateTime: 2023-04-28 11:25* @Version: 1.0*/public class DirectSelectionSort {public static void main(String[] args) {int[] numArray={2,8,1,4...
/// /// 选择排序算法 /// public static void SelectionSortAlgorithmMain() { int[] array = { 64, 25, 12, 22, 11, 99, 3, 100 }; Console.WriteLine("原始数组: "); PrintArray(array); SelectionSortAlgorithm(array); Console.WriteLine("排序后的数组: "); PrintArray(array); } ...
/// ///选择排序算法 /// publicstaticvoidSelectionSortAlgorithmMain() { int[]array={64,25,12,22,11,99,3,100}; Console.WriteLine("原始数组:"); PrintArray(array); SelectionSortAlgorithm(array); Console.WriteLine("排序后的数组:"); PrintArray(array); } staticvoidSelectionSortAlgorithm(int...
packagesorting;importjava.util.Arrays;importorg.junit.Test;publicclassSelectionSorting {int[] items = { 4, 6, 1, 3, 7};intstep = 0;//① 相邻//② 差一步//③ n个数可产生 n-1 对//④ 逐块收复失地@Testpublicvoidsort() {for(inti = 0; i < items.length - 1; i++) {for(intj =...
Selection sort is one of the simplest sorting algorithms. It is easy to implement but it is not very efficient. The algorithm divides the input list into two parts: the sublist of items already sorted, which is built up from left to right at the front (left) of the list, and the ...
The names of sorting techniques are Selection sort, Insertion sort, Bubble sort, Shell sort, Merge sort, Quick sort and many more. There is no one sorting method that is best for every situation. In this paper, an enhanced version of the selection sort algorithm is presented. It is ...
Selection Sort Algorithm selectionSort(array, size) for i from 0 to size - 1dosetiastheindexofthecurrentminimumforjfromi +1tosize-1doifarray[j] <array[currentminimum]setjasthenewcurrentminimumindexifcurrentminimumisnoti swaparray[i]witharray[currentminimum]endselectionSort ...
Let's implement the selection sort algorithm: public void sort(int arr[]) { int n=arr.length; int min_ind; for(int i=0;i<n;i++) { min_ind = i; for(int j=i+1;j<n;j++) { if(arr[min_ind] > arr[j]) { min_ind =j; ...
其实基本排序并不是一个排序方法,而是集中基本的排序方法的定位,我使用这个名字也是因为《algorithm》书中将下面几种排序方法放在一章中,而这一章节的名字成为基本排序(elementary sort)。 书中包括三种排序方法:选择排序(selection sort)、插入排序(insertion sort)和希尔排序(shell sort) ...
* @BelongsPackage: com.wzl.Algorithm.DirectSelectionSort * @Author: Wuzilong * @Description: 选择排序 * @CreateTime: 2023-04-28 11:25 * @Version: 1.0 */ public class DirectSelectionSort { public static void main(String[] args) {