5 ms·
Having N > 2 will require you to do a sort on the pivots :P Also you will require that the array size be at least N. N = 2 is a perfect size -- size = 0 -> no
by GrandMasterBirt 17y ago
Having N > 2 will require you to do a sort on the pivots :P Also you will require that the array size be at least N. N = 2 is a perfect size --
size = 0 -> no sort
size = 1 -> no sort
size = 2 -> pivots can be made, thus can be sorted
etc.
- iclelland 17y agoHaving N > 1 requires you to do a sort on the pivots. From the algorithm: 3. P1 must be less than P2, otherwise they are swapped.
- swac 17y agoIf you determine the number of pivots when you write the algorithm, they could be sorted in constant time. It would just require a lot of if-else branching...