Firstly, you have a slight misconception regarding the swap function. Let's say the function prototype is
swap(int array[], int i, int j)
The swap function replaces the numbers in the location array [i] and array [j]. Thus, the swap function changes the elements in the array. So the line is -
swap(v, left, (left + right) / 2);
Means that the middle element in the array is replaced by the left-most element. Obviously, quicksort takes the middle element as a hinge. This exchange does not affect local variables or parameters. According to your data entry example, the value is 'left' = 0 and the value is right = '8', even after replacement. Here you are confused. Array elements are swapped, not variable values. So now the line is -
last = left;
does, the "last" indicates the location of the rotation ("left"), so here the value of "last" = 0 is not 4. So, the loop,
for(i = left + 1; i <= right; i++)
It works from i = 1 to 8. By the way, you forgot the semicolon ..! Then the line,
if(v[i] < v[left])
checks if the current element ('v [i]') is smaller than the pivot point ('v [left]') or not. Then, respectively, swaps the smaller elements, as in a line,
swap(v, ++last, i);
from the location (last + 1) to the place where it increases. So, the elements to the left of the "last" are smaller than the pivot points, and the elements to the right are larger. I think that you are missing one more line, where we return the anchor point to the middle, which was in the place "v [left]" during the execution of the algorithm. Then recursive calls play their part. If you're looking for help sorting quickly, this is a good place to start!
Hope my answer helped you, if so, let me know ..! βΊ