Consider the following C++ function f, which calls the function swap. Assume that swap exists and simply swaps the contents of its two arguments. Do not be concerned with f’s purpose.
void f(int theArray[], int n) {
for (int j = 0; j < n;="" ++j)="">
int i = 0;
while (i <= j)="">=>
if (theArray[i] <>
swap(theArray[i], theArray[j]); i++;
} // end while
} // end for
}// end
What is the big-O for the number of comparisons performed in f?
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here