Skip to content
Advertisement

Python quicksort – one list – swaps

**I need to make a quicksort algorithm but so that it uses only one list and does swaps inside of it. I managed to make it “sort” or position the first element but now i don’t know how to implement the recursion. The biggest problem I’m having is how to recursively work on a part of the list instead of making the new one. Here is my code: ——————————————————————————-** New code, same problem.

Here is my code. It does the job but gets stuck in the loop.

JavaScript

Can someone give me any suggestions, I’m lost. Can’t find whats wrong or how to fix it. Know its messy but cant do better atm :D

Advertisement

Answer

Write it like this:

JavaScript

lo and hi are the smallest and largest indexes you should look at in li, respectively.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement