Bubble Sort Java

import org.testng.annotations.Test;

public class BubbleSortTest {

public void bsort(int a[])

{

int temp;

for (int i=0;i<a.length-1;i++)

{

for (int j=i+1;j<a.length;j++)

{

if(a[i]>a[j])

{

temp=a[i];

a[i]=a[j];

a[j]=temp;

}

}

}

for(int i=0;i<a.length;i++)

{

System.out.println(a[i]);

}

}

  @Test

  public void testBSort() {

  int a[]={10,5,8,1};

  bsort(a);

  }

}

Advertisements

About qainterviews

Software Geek,QA Expert,Blogger
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s