Question
ONE // this abstract class is going to implement a generic bubble sort public abstract class Sorting { public final void bubbleSort(int[] nArray) { int
ONE
// this abstract class is going to implement a generic bubble sort
public abstract class Sorting { public final void bubbleSort(int[] nArray) { int nRounds, nElt; boolean bHasExchanged; bHasExchanged = false; nRounds = 0; while (!bHasExchanged) { for (nElt = 0; nElt<(nArray.length - nRounds) ; nElt++) { if (boolNeedExchange(nArray, nArray[nElt], nArray[nElt+1])) { Swap(nArray, nElt, (nElt+1)); bHasExchanged = true; } } nRounds++; } } private final void Swap(int[] nArray, int first, int second) { int nTemp = nArray[first]; nArray[first] = nArray[second]; nArray[second]= nTemp; } //Template methods protected abstract boolean boolNeedExchange(int[] nArray, int first, int second); }
TWO
// provides an ascending sort
public class AscendingSort extends Sorting {
@Override protected boolean boolNeedEcchange(int[] nArray, int first, int second) { boolean needExchange = false; if(first } CORRECT THE FOLLOWING CODES PLEASE
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started