Quick sort pivot is middle element

closed account (1vf9z8AR)
There are absolutely no resources for quicksort with the middle element as the pivot.
Can anyone give me a link to learn it?
My own implementations are failing probably because I don't know what to do.
Huh?
https://en.wikipedia.org/wiki/Quicksort#Choice_of_pivot

The pivot point is just a number. The algorithm after that point doesn't actually care about the choice.

> no resources for quicksort with the middle element as the pivot
Why does this read as "I can't find ready made source code I can copy and paste".

> My own implementations are failing probably because I don't know what to do.
Perhaps you could post your own implementation so we can help you diagnose where you went wrong, and learn something new (like how to diagnose problems).

Choosing a pivot from the middle of your structure is fine and there's likely dozens of implementations of qsort out there that does this. But you could also choose a pivot at random and this too will reduce the chance of encountering worst case O(n^2) time complexity. If you're unable to implement the algorithm, then you should ensure that you fully understand how the algorithm actually works. Once you know how it works, then you'll be able to put a code together.
closed account (1vf9z8AR)
I can do from left or right most pivot
Topic archived. No new replies allowed.