int size arr size()/partition array int partdex arr partitionit( size- pivot)system out println("partition is at index partdex)arr display()/display sorted array /end main(/end class partitionapp the main(routine creates an arraypar object that holds items of type double the pivot value is fixed at the routine inserts random values into arraypardisplays thempartitions them by calling the partitionit(methodand displays them again here' some sample outputa= pivot is partition is at index = you can see that the partition is successfulthe first eight numbers are all smaller than the pivot value of the last eight are all larger notice that the partitioning process doesn' necessarily divide the array in half as it does in this examplethat depends on the pivot value and key values of the data there may be many more items in one group than in the other the partition algorithm the partitioning algorithm works by starting with two pointersone at each end of the array (we use the term pointers to mean indices that point to array elementsnot +pointers the pointer on the leftleftptrmoves toward the rightand the one of the rightrightptrmoves toward the left notice that leftptr and rightptr in the partition java program correspond to leftscan and rightscan in the partition workshop applet actually leftptr is initialized to one position to the left of the first celland rightptr to one position to the right of the last cellbecause they will be incremented and decrementedrespectivelybefore they're used stopping and swapping when leftptr encounters data item smaller than the pivot valueit keeps goingbecause that item is in the right place howeverwhen it encounters an item larger than the pivot valueit stops similarlywhen rightptr encounters an item larger than the pivotit keeps goingbut when it finds smaller itemit also stops two inner while loopsthe first for leftptr and the second for rightptrcontrol the scanning process pointer stops because its while loop exits here' simplified version of the code that scans for out-of-place itemswhilethearray[++leftptrpivot /(nopwhilethearray[--rightptrpivot /(nopswap(leftptrrightptr) /find bigger item /find smaller item /swap elements