i made this code but i'm stuck in :

the fundamental operation in the described algorithm? How many operations does it take?

What is the invariant of this sorting algorithm?

the code :

public class Ass { public static void swap(int [] x) { int i = 0 ; while (i<x.length){ for (int j = 0 ; j<x.length ; j++){ int b = 0 ; if ( x[j] > x[i] ) { b++ ; } if (b!=0) { int tmp = x[i] ; x[i]=x[j] ; x[j]= tmp ; } } i++ ; } } public static void main (String [] args) { int [] array = {5,7,3,6,9,4,2} ; swap(array) ; int m = array.length ; for (int k = 0 ; k<array.length ; k++) System.out.print(array[k] + " "); } }