How do I make this recursive?
This is tail recursive, which is much better I'm trying to find ways to make tail recursive recursive and vice versa and I don't know how.
I've understood how to make recursive functions iterative but I for some reason cant tell the difference between recursion/tail recursion
>>337567
That's because tail recursion is a type of recursion.
Literally the only difference is that tail recursion is recursion where there's only one call, with no code that changes the state after it. This lets the compiler/interpreter get away with not using a stack, because there's no (meaningful) instructions to jump back to, so it can jump straight back to whatever called the tail-recursive function.
You're not going to see a tail-recursive sort, because the whole point of a recursive sort is that it partitions the search space by calling itself more than one time.
>>337574
Is it even possible to make this non-tail recursive then?
>>337581
It's already non-tail-recursive, because it calls itself twice.
If you want to make anything from tail-recursive to not tail-recursive, just do anything with a side-effect after the recursive call. The compiler can't just remove side-effects, so it has to keep a stack so all the side-effects happen.
>>337593
Wouldnt it be recursive if it was:
return Quicksort(A,p,q-1) + Quicksort(A,q+1,r) ?
>>337598
In what scenario would that return make sense? Quicksort is an in-place algorithm.