What are the Big-Oh and Omega orders of the following code fragment? What is Tilde approximation?
The fragment is prameterized on the variable n. Assume that you are measuring the number of swap calls.
for(int j=0;j<n-1;j++){
     int z = j;
     for (int i=j+1; i<n; i++){
            if(a[i] < a[z]){
                      z=i;}
}
if(z!= j){
      swap(a[j], a[z]); //count these
     }
}

Comments

Popular posts from this blog

Audit Reports

Smith et al. (1998) NTVS