These are two very similar algorithms, all of which are two nested loops. Before looking online a lot of people will choose sort when bubble sort with, I am afraid later mixed, record.
Select sort
/** * Select sort * @Title: Getselectsort * @Description: TODO (here is a word describing the effect of this method) * @param @param arr * @pa Ram @return Settings file * @return int[] return type * @throws*/ Public Static int[] Getselectsort (int[] arr) { for(inti =0; i < arr.length; i++) { inttemp =0; for(intj =0; J < Arr.length; J + +) { if(Arr[i] <Arr[j]) {Temp=Arr[i]; Arr[i]=Arr[j]; ARR[J]=temp; Continue; } } } returnarr; }
Bubble sort
/*** Bubble Sort * @Title: Getbubblesort * @Description: TODO (here is a word describing the effect of this method) *@param @paramarr *@param @returnSettings File *@returnint[] return type *@throws */ Public Static int[] Getbubblesort (int[] arr) { /*** Outer Loop-1 is because the last number does not compare * memory loop-1 is because prevent array out of bounds * memory loop-I bubbling feature outer City Loop once, has determined a bit value, so the value of this bit does not participate in the next loop * The outer layer is once per cycle, the inner layers are less cyclic once, the number of loops is determined, the memory is sorted*/ for(inti = 0; i < arr.length-1; i++) { inttemp = 0; for(intj = 0; J < Arr.length-1-i; J + +) { if(Arr[j] > arr[j+1]) {temp=Arr[j]; ARR[J]= Arr[j+1]; Arr[j+1] =temp; Continue; } } } returnarr; }
Select sort and Bubble sort