Implementing Quick Sort in Java

Quick Sort is sorting algorithm based on divide and conquer method. For more information about quick sort you can check this and this post.

import java.io.*;
class qsort
{
int arr[],l,u;
int arrt[];
int size;
public qsort(int ele[])
{
arr=ele;
l=0;
size=arr.length;
u=arr.length-1;
}
public void startsort()
{
sort(l,u);
}
public void sort(int lb,int ub)
{
if(lb>ub)
return;
int arrt[]=new int [size];
int tc=lb;
int pivot=arr[lb];
if(lb==ub)
{
arrt[lb]=pivot;
return;
}
for(int i=lb;i<=ub;i++) { if(pivot>arr[i])
{
arrt[tc]=arr[i];
tc++;
}
else
continue;
}
int index=tc;
arrt[tc]=pivot;
tc++;
for(int i=lb;i<=ub;i++) { if(pivot

Leave a Reply

Your email address will not be published. Required fields are marked *