class Bubblesort
{
void sort(int a[])
{
int i,temp,n;
for(i=0;i<16;i++)
{
for(int j=i;j<16;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
for(i=0;i<16;i++)
{
System.out.println("arr["+i+"] = "+a[i]);
}
}
}
class Bubblesortmain
{
public static void main(String args[])
{
Bubblesort b=new Bubblesort();
int a[]={8,7,5,9,2,7,4,3,45,78,65,2,8,79,100,114};
long start = System.currentTimeMillis();
b.sort(a);
long end = System.currentTimeMillis();
System.out.println("Execution time was "+(end-start)+" ms.");
}
}
0 comments:
Post a Comment