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 t o do a b u b b l e s o r t on t h e a r r a y
?/
public void b u b b l e S o r t ( )
{
i n t maxIndex = a . l e n g t h ? 1 ;
i n t numSteps = 0 ;
f o r ( i n t i = maxIndex ; i >= 0 ; i ??)
{
f o r ( i nt j = 0 ; j < i ; j ++)
{
Speed
numSteps++;
i f ( a [ j ] . compareTo ( a [ j +1]) > 0 )
{
swap ( j , j +1);
}
}
t h i s . p r i n t A r r a y ( ” a f t e r l o o p body when i = ” + i ) ;
}
System . out . p r i n t l n ( ”#s t e p s : ”+numSteps ) ;
}
```
You might also like to view...
What is the space complexity of the following program?
double a = 0, b = 0; for (int x = 0; x <= M; x++ ) { a += Math.random(); } for (int x = 0; x <= N; x++ ) { b += Math.random(); } a. O(1) b. O(N+M) c. O(N*M) d. O(N)
Search engines that search other search engines are called
a. megasearch engines. b. betasearch engines. c. gigasearch engines. d. metasearch engines.
The process of running a program over and over to find errors and make sure the program behaves in the way it should is known as ________
Fill in the blank(s) with correct word
You can customize a motion path to end in a specific location on a slide
Indicate whether the statement is true or false