Quote:
i have tried to replace n by any no but then also its not working
I think it is time for you to stop guessing what your code is doing. It is time to see your code executing and ensuring that it does what you expect.
The debugger is your friend. It will show you what your code is really doing.
Follow the execution step by step, inspect variables and you will see that there is a point where it stop doing what you expect.
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[
^]
http://docs.oracle.com/javase/7/docs/technotes/tools/windows/jdb.html[
^]
https://www.jetbrains.com/idea/help/debugging-your-first-java-application.html[
^]
Potential problem: you don't check that the number of values don't exeed the size of the array.
In this code, a[j] is excluded from sorting:
j= partition(a,p,q+1);
quicksort(p,j-1,a);
quicksort(j+1,q,a);
My mistake, the problem is not this. looks like you are messing with indexes, the debugger is probably the best way to see what append.