sorting - Java Selection sort -
a - array containing list of numbers numitems - number of numbers in list = 0 numitems - 1 j = i+1 numitems if a[i] > a[j] // swap entries temp = a[i] a[i] = a[j] a[j] = temp end if next j next i\ can comeone convert java me? i've tried can't figure out.
public static void selectionsort1(int[] x) { (int i=0; i<x.length-1; i++) { (int j=i+1; j<x.length; j++) { if (x[i] > x[j]) { // exchange elements int temp = x[i]; x[i] = x[j]; x[j] = temp; } } } }
Comments
Post a Comment