Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The instructions to answer my question are below in bulletpoints, and write the

ID: 3927487 • Letter: T

Question

The instructions to answer my question are below in bulletpoints, and write the code in Java, thank you.

A classic 0(N^2) algorithm is Bubble Sort, where a loop insicle of a loop is used to sort the data Write a Bubble Sort for the array of integers theArray that orders them low to high Use the variable outvar on the outer loop, start the target position at the end of the array and move backwards Use the variable innerval on the inner loop, start the beginning of the array and move towards the outer target Do not write a separate swap method, code the swap inside the inner loop using the variable temp Do not declare or initialize theArray, do not declare outvar. innerval, temp it will be done for you Write only the 2 loops with an if inside them that does the swap

Explanation / Answer

for(outvar=theArray.length-1;outvar>-1;outvar--){
           for(interval=0;interval<outvar;interval++){
               if(theArray[outvar]<theArray[interval]){
                   temp = theArray[outvar];
                   theArray[outvar] = theArray[interval];
                   theArray[interval] = temp;
               }
           }
       }

/* sample output

array = {5,4,3,2,1}

1 2 3 4 5

*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote