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

1 Expert Approved Answer
Step: 1 Unlock

To correct the provided code snippets for implementing a generic bubble sort using an abstract class with a template method pattern Ill address a few ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!