How to derive the total number of primitive operations used
How to derive the total number of primitive operations used in this algorithm?
void selectionSort(int[] array, int startlndex) {if (startlndex >= array.length - 1) return; int minlndex = startlndex; for (int index = startlndex + 1; indexSolution
ublic class SelectionSort {
 private int exchanges, comparisons;
public void selectionSort(int[] x) {
 for (int i=0; i<x.length-1; i++) {
 for (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;
 exchanges++;
 }
 comparisons++;
 }
 }
 System.out.println(\"SelSort_Exchanges: \"+exchanges);
 System.out.println(\"SelSort_Comparisons: \"+comparisons);
 System.out.println(\"SelSort_Operations: \"+(exchanges+comparisons));
 }
 }
SelSort_Comparisons: 45
 SelSort_Exchanges: 27
 SelSort_Operations: 72
![How to derive the total number of primitive operations used in this algorithm? void selectionSort(int[] array, int startlndex) {if (startlndex >= array.lengt How to derive the total number of primitive operations used in this algorithm? void selectionSort(int[] array, int startlndex) {if (startlndex >= array.lengt](/WebImages/29/how-to-derive-the-total-number-of-primitive-operations-used-1079108-1761566413-0.webp)
