The code snippet swaps the values of array[left]
and array[right]
, nothing more.
It does so by first memorizing the value of array[left]
in a temporary variable temp
because it soon gets overridden.
After that it overrides the value at array[left]
with the value stored in array[right]
.
Finally it writes the memorized value of the old array[left]
, stored in temp
, to array[right]
.
Here is a small illustration of the process:
0
solved Can anyone explain me this quicksort example?