I am attempting to implement quick sort in Python without using recursion, but all reference implementations or pseudo codes I have found so far use recursion.
The reason for this is that I will adapt this non-recursive implementation to run on GPUs using Numba, and I cannot make recursive calls there.
Is there a quick sort implementation for a 1d array (say, a Numpy array or Python list) that does not use recursion?
Thanks,
Eduardo
The standard unix/linux qsort is implemented without recursion for efficiency. You could look that up, or just translate the code in this answer to python:
Can quicksort be implemented in C without stack and recursion?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With