cannot able to identify my error, checked a-lot pls go through it it does not produce the correct output, the code is implementation of quick sort through java. this code produces the same output as input, as i am new to java and algorithms I am not able to figure it out.
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
int a[]=new int[5];
Scanner s=new Scanner(System.in);
for(int i=0;i<5;i++)
a[i]=s.nextInt();
quick(a,0,4);
for(int i=0;i<5;i++)
System.out.print(a[i]+" ");
}
public static void quick(int a[],int s,int l)
{
if(s<l)
{
System.out.println("in quick");
int pi=part(a,s,l);
quick(a,s,pi-1);
quick(a,pi+1,l);
}
}
public static int part(int a[],int s,int l)
{
System.out.println("in part");
int pivot=a[l];
int pin=s;
for(int i=s;i<l;i++)
{
if(a[i]<=pivot)
{
swap(a[i],a[pin]);
pin++;
}
}
swap(a[pin],a[l]);
System.out.println(pin);
return pin;
}
public static void swap(int a,int b)
{
System.out.println("in swap");
int t;
t=a;
a=b;
b=t;
}
}