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 ) ;
}
```
You might also like to view...
You can place any large block of text within a _____ section to avoid inadvertently inserting a character that would be misinterpreted by an XML processor (such as the ampersand symbol).
A. baseline B. header C. CDATA D. pcdata
Which of the following identifies and removes unsolicited e-mail?
A) presorting filter B) junk e-mail filter C) spim filter D) spam filter
A sparkline is a tiny table used to show data trends
Indicate whether the statement is true or false
With a three-generation backup policy, the grandparent is which of the following?
A. most recent copy of the file B. second oldest copy of the file C. oldest copy of the file D. original file