Java Reference
In-Depth Information
Notice that sort relies on two for loops. The inner loop checks adjacent elements in
the array, looking for out-of-order elements. When an out-of-order element pair is
found, the two elements are exchanged. With each pass, the smallest of the remaining
elements moves into its proper location. The outer loop causes this process to repeat
until the entire array has been sorted.
3. Here is the entire Bubble program:
Search WWH ::




Custom Search