Get Some Free Products at your Door Step. Just feed ur Address in dis Link...!!

Monday, October 24, 2011

bubble sort in java

public class BubbleSort
{
public static void main(String ar[])
{
BubbleSort bs = new BubbleSort();
int[] d = {30,24,0,54,63};
bs.sort(d);
}

//______________Bubble sort function____________________

public void sort(int[] data)
{
for(int i=data.length;i>0;i--)
{
for(int j=0;jdata[j+1])
{
int x=data[j+1];
data[j+1]=data[j];
data[j]= x;
}
}
}
display(data);
}
//___________________________________________________

public void display(int[] data)
{
for(int i=0;i {
System.out.println(" " +data[i]);
}
}
}

No comments:

Post a Comment