in studying Quicksort using the book "Introduction to Algorithms" by Cormen, Leiserson, Rivest and Stein, they describe in order to show correctness, an invariant must hold for the 3 stages of the loop, the initialization, the maintenance and termination of the loop.
Here is the algorithm I'm referencing:
Might someone help me understand conditions
1) if $p \leq k \leq i$ then $A[k] \leq x$
In the algorithm when for example, $p$ is $1$, won't $i$ be $0$.... How would this hold, since before the for loop we have
i = p-1
2) if $i + 1 \leq k \leq j - 1 $ then $A[k] > x$
In the algorithm for example, when we first enter the for loop, and j = 1, then $i$ would be 0.... I don't see how this works.