Bubble Sort
Description
This applet demonstrates the working of the Bubble Sort algorithm.
- Create: Type a value between 5 and 100 in the text field, and click "Create" to create a randomly generated
array of the specified size.
- Sort: Displays the process of sorting the array using Bubble Sort algorithm. The applet uses a fast display
mode, if the input value is greater than 20.
Code
public void bubbleSort(){
int temp;
for(int j=size-1; j > 0; j--){
for(int i=0; i < j; i++){
if(arr[i] > arr[i+1]){
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
}
|
Data Structures and Algorithms
Java Applets Centre
R. Mukundan
Department of Computer Science
University of Canterbury
Private Bag 4800, Christchurch
New Zealand.