-
-
Save itsknk/5c182ce624d398aa118c1c2b7e979cf9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class bubbleSort | |
{ | |
public static void main(String args[]) | |
{ | |
int arr[] = { 2,8,5,3,9,4,1 }; | |
for(int i=0; i<arr.length; i++) | |
{ | |
for(int j=1; j<arr.length-i; j++) | |
{ | |
if(arr[j-1] > arr[j]) | |
{ | |
int temp = arr[j-1]; | |
arr[j-1] = arr[j]; | |
arr[j] = temp; | |
} | |
} | |
} | |
for(int i=0; i<arr.length; i++) | |
{ | |
System.out.print(arr[i]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment