I am trying to calculate the primitive operations in a section of code written in Java. Here is what I have come up so far:
void bubbleSort(int array[]) Primitive Operations int n = array.length`; 2 for (int i = 0; i < n - 1; i++) 3n – 1 = 1 + n + 2(n-1) for (int j = 0; j < n-i-1; j++) ∑_(i=0)^(n-1)〖(3j-1)〗 { if (array[j] > array[j+1]) ∑_(i=0)^(n-1) ∑_(j=0)^(n-1)〖(4)〗= ∑_(i=0)^(n-1) 4n { int temp = array[j]; ∑_(i=0)^(n-1) ∑_(j=0)^(n-1)〖(2)〗= ∑_(i=0)^(n-1) 2n array[j] = array[j+1]; ∑_(i=0)^(n-1) ∑_(j=0)^(n-1)〖(3)〗= ∑_(i=0)^(n-1) 3n array[j+1] = temp; ∑_(i=0)^(n-1) ∑_(j=0)^(n-1)〖(3)〗= ∑_(i=0)^(n-1) 3n } } }
One thing that I am uncertain is the inner loop of ∑_(i=0)^(n-1)〖(3j-1)〗 since there are two variables in the testing clause of the loop.
Thanks in advance for your time.
Paul