since greater_than_pivot_index less_than_pivot_indexthe body of the if statement swaps the element at those indexes the else condition breaks the infinite loop any time greater_than_pivot_index becomes greater than less_than_pivot_index in such conditionit means that greater_than_pivot_index and less_than_pivot_index have crossed over each other our array now looks like thisthe break statement is executed when less_than_pivot_index is equal to and greater_than_pivot_index is equal to as soon as we exit the while loopwe interchange the element at unsorted_array[less_than_pivot_indexwith that of less_than_pivot_indexwhich is returned as the index of the pivotunsorted_array[pivot_index]=unsorted_array[less_than_pivot_indexunsorted_array[less_than_pivot_index]=pivot return less_than_pivot_index the image below shows how the code interchanges with as the last step in the partitioning process