posted 12 years ago

I am needing someone to give me a hint...steer me in the right direction as to how I should approach this problem. The key, I'm thinking, is obtaining some value for n. With such a value I should be able to solve the problem. Any thoughts? Suggestions. Thanks in advance.

Consider the following Java method

===========================================================================

{

{

{

{

temp = theArray[i];

theArray[i] = theArray[j];

theArray[j] = temp;

} //end if

++i;

} //end while

} //end for

} //end f

Consider the following Java method

*f*. Do not be concerned with*f*'s purpose. How many comparisons does f perform?===========================================================================

**public static void**f(*int*[] theArray,*int*n){

**int**temp;**for**(**int**j = 0; j < n; ++j){

**int**i = 0;**while**(i<=j){

**if**(theArray[i] < (theArray[j])){

temp = theArray[i];

theArray[i] = theArray[j];

theArray[j] = temp;

} //end if

++i;

} //end while

} //end for

} //end f

Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |