3 ms·
Both of your questions have the same answer. (x:xs) means x is the first element and xs is the rest.
by zests 7y ago
Both of your questions have the same answer. (x:xs) means x is the first element and xs is the rest.
- magicalhippo 7y agoAha! 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.