I am confused with the optimized quick sort little help please

```
public static void quickSort(int []A,int p,int q){
while(p<=q)
{
int r = partition(A, p,q);
quickSort(A, p, r);
quickSort(A, r+1, q);
}
}
static int partition(int []A, int p, int q)
{
int a=A[p];
int lp=p-1;
int rp=q+1;
while(A[rp]<a)
{
rp=rp-1;
while(A[rp]<a)
lp++;
while(A[lp]>a)
rp--;
if(lp>rp)
{
int temp=A[lp];
A[lp]=A[rp];
A[rp]=temp;
}
}
return rp;
}
```