+ 1
Optimising my Quick sort algorithm (does it operate in-place?)
Hey, my Quick sort algorithm works just fine and it's fairly quick I'd say, but could someone please check it and tell me if it operates in-place (doesn't use any additional space except for the given list)? I wrote it that way and I'm 90% sure it does but these things are tricky so I said I'd double check. Also any optimisations come in mind? I appreciate any help :) https://code.sololearn.com/cA12a4A5a16A/?ref=app
2 odpowiedzi
+ 2
i would say it's in-place
- Since you are not creating any extra list or array.... each operation you do is on same list... so it's in-place
- But in each operation the list keeps changing its size(pop and append or pop and insert)
- for optimization, i suggest u to use swap like a, b=b, a instead of deleting and inserting... because insert() takes a lot of time... at least greater than a simple swap...
also that's a good piece of implementation...
0
NaSaPaKri Thanks for your answer!