Look up how to do a bubble sort. Write a method to do a bubble sort of an array of names. See the StringArraySorter class in the directory bookClassesFinal.
What will be an ideal response?
```
/**
* Method to do a b u b b l e s o r t on the ar ray
*/
public void bubbleSor t ( )
{
int maxIndex = a . l eng th ¡ 1 ;
int numSteps = 0 ;
for ( int i = maxIndex ; i >= 0 ; i¡¡)
{
for ( int j = 0 ; j < i ; j++)
numSteps++;
i f ( a [ j ] . compareTo ( a [ j +1]) > 0)
{
swap ( j , j +1);
}
}
this . pr intAr ray ( " a f t e r loop body when i = " + i ) ;
}
System . out . p r i n t l n ( "#s t eps : "+numSteps ) ;
}
```
Computer Science & Information Technology
You might also like to view...
With ________ selected, the database will be compacted and repaired each time it is closed
A) Compact & Repair B) Compact on Close C) Compact Objects on Close D) Compact Application
Computer Science & Information Technology
What can data macros be used for?
What will be an ideal response?
Computer Science & Information Technology