exits when an item smaller than pivot is found when both these loops exitboth leftptr and rightptr point to items that are in the wrong part of the arrayso these items are swapped after the swapthe two pointers continue onagain stopping at items that are in the wrong part of the array and swapping them all this activity is nested in an outer while loopas can be seen in the partitionit(method in listing when the two pointers eventually meetthe partitioning process is complete and this outer while loop exits you can watch the pointers in action when you run the partition workshop applet with bars these pointersrepresented by blue arrowsstart at opposite ends of the array and move toward each otherstopping and swapping as they go the bars between them are unpartitionedthose they've already passed over are partitioned when they meetthe entire array is partitioned handling unusual data if we were sure that there was data item at the right end of the array that was smaller than the pivot valueand an item at the left end that was largerthe simplified while loops previously shown would work fine unfortunatelythe algorithm may be called upon to partition data that isn' so well organized if all the data is smaller than the pivot valuefor examplethe leftptr variable will go all the way across the arraylooking in vain for larger itemand fall off the right endcreating an array index out of bounds exception similar fate will befall rightptr if all the data is larger than the pivot value to avoid these problemsextra tests must be placed in the while loops to check for the ends of the arrayleftptrleft in the second this can be seen in context in listing in the section on quicksortwe'll see that clever pivot-selection process can eliminate these end-of-array tests eliminating code from inner loops is always good idea if you want to make program run faster delicate code the code in the while loops is rather delicate for exampleyou might be tempted to remove the increment operators from the inner while loops and use them to replace the nop statements (nop refers to statement consisting only of semicolonand means no operation for exampleyou might try to change thiswhile(leftptr right &thearray[++leftptrpivot/(nopto thiswhile(leftptr right &thearray[leftptrpivot++leftptrand similarly for the other inner while loop this would make it possible for the initial values of the pointers to be left and rightwhich is somewhat clearer than left- and right+ howeverthese changes result in the pointers being incremented only when the condition