Click here to Skip to main content
15,504,830 members
Please Sign up or sign in to vote.
1.22/5 (2 votes)
See more:
void partition(int arr[],int low,int high){

    int mid;


in the above program is the first recursion will occur twice for the second recursion ? deduce me this two recursion process.

Any help is appreciated.
Thanks mahbub.
Updated 31-Dec-13 22:45pm
Sergey Alexandrovich Kryukov 1-Jan-14 3:55am    
What do you mean "how"? Exactly how it is written. You can deduce everything mentally or using the debugger.
Otherwise, you approach is counter-productive.
If this is not your code, this is even more counter-productive; then solve problems and write code by yourself, it will be millions times more useful.
mahbubur rahman 1-Jan-14 4:02am    
i exactly mean if i use low=0;high=6; then how the steps works ?
Sergey Alexandrovich Kryukov 1-Jan-14 4:08am    
I just gave you an advice, please use it.
Amarnath S 1-Jan-14 8:59am    
Can you not debug and check?

1 solution

We can't help you with this: we don't have access to your data which controls exactly what happens.

So you will have to do this yourself.
Start by putting a breakpoint on the first line in the function, and running your application. When it hits the breakpoint, write down what is in arr, low and high and single step through the code, watching what happens to the various variables.

However, in your example, pretty much nothing will happen, since all you do is recursively call the method with progressively smaller intervals until integer division means low and high work out the same...
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900