: Answer 1: that doesn't matter, actually. Usually we don't have many equal items in the array, so skipping equal items gives no significant gain.  Generally the quicksort works quite poorly on arrays with lots of equal items. Those items lead to unbalanced partitioning results (often it is 'one and the rest') which causes a rapid growth of recursion depth. If you need to sort such arrays and want to use quicksort for it, consider some more sophisticated partitioning routine, which would give three sub-arrays: left one with items less than the pivot, central part with (possibly many) items equal to the pivot, and the right one with items greater than the pivot.  
 : Answer 2: That is even more pointless. In optimistic case, partitioning routine would split the array into halves, which means approx. half of items are bigger than the pivot. So it's 1:2 chance the first item will get 'swapped' with itself, same 1:2 for the second one and so on... The expected number of self-swapped items for this case is 2.  For less optimistic case it might be bigger, anyway it is still a small number. Your change inserts additional code which is executed for every item to avoid self-swap of a few items of the array being partitioned. That will effectively make the routine slower.  Your modification would bring some important speed-up if your input data are already sorted or 'almost' sorted. But in that case you can use other algorithms, which work better on such data than a very general quicksort. 
 :