3 ms·
Aha! Thanks. Obviously picking first element as pivot makes for a very poor Quicksort. Though I presume a better approach, say median of first, mid and last el
by magicalhippo 7y ago
Aha! Thanks.
Obviously picking first element as pivot makes for a very poor Quicksort. Though I presume a better approach, say median of first, mid and last elements, would add but an extra line?
- sullyj3 7y agoThe reason the first element is used as the pivot is that these are linked lists, not arrays, so it would take linear time to access the middle and end. This isn't a real quicksort.