Mental Model
Partition divides an array into two parts around a pivot so smaller values go left and larger go right. Lomuto and Hoare are two ways to do this.
Analogy: Imagine sorting books on a shelf by height: Lomuto picks one book as a divider and moves shorter books left and taller right, while Hoare uses two hands from both ends to swap books until they meet.
Array: [5, 3, 8, 4, 2] Pivot: 2 (Lomuto picks last element) Indexes: i and j move to rearrange Initial: [5, 3, 8, 4, 2] i= -1, j=0 After partition: [2, 3, 8, 4, 5] Pivot at index 0