import org.testng.annotations.Test;

public class QuickSorts {

int []numbers;

publicvoid sort(int []values)

{

numbers=values;

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

{

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

}

quicksort(0,numbers.length-1);

System.out.println(“Values after sort are”);

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

{

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

}

}

public int [] quicksort(int low,int high)

{

int i=low,j=high;

int pivot=numbers[low+high/2];

while(i<=j)

{

while(numbers[i]<pivot)

i++;

while(numbers[j]>pivot )

j–;

if(i<=j)

{

int temp;

temp=numbers[i];

numbers[i]=numbers[j];

numbers[j]=temp;

i++;

j–;

}

}//i<=j

if(low<j)

quicksort(low,j);

if(i<high)

quicksort(i,high);

return numbers;

}

@Test

public void testSort() {

int arr[]={2,7,50,28};

sort(arr);

}

}

### Like this:

Like Loading...

*Related*

## About qainterviews

Software Geek,QA Expert,Blogger