the itemsand yet it successfully avoids picking the largest or smallest item in cases where the data is already sorted or inversely sorted there are probably some pathological arrangements of data where the median-of-three scheme works poorlybut normally it' fast and effective technique for finding the pivot besides picking the pivot more effectivelythe median of three approach has an additional benefitwe can dispense with the rightptr>left test in the second inside while loopleading to small increase in the algorithm' speed how is this possiblethe test can be eliminated because we can use the median-of-three approach to not only select the pivotbut also to sort the three elements used in the selection process figure shows how this looks figure sorting the leftcenterand right elements once these three elements are sortedand the median item is selected as the pivotwe are guaranteed that the element at the left end of the subarray is less than (or equal tothe pivotand the element at the right end is greater than (or equal tothe pivot this means that the leftptr and rightptr indices can' step beyond the right or left ends of the arrayrespectivelyeven if we remove the leftptr>right and rightptr<left tests (the pointer will stopthinking it needs to swap the itemonly to find that it has crossed the other pointer and the partition is complete the values at left and right act as sentinels to keep leftptr and rightptr confined to valid array values another small benefit to median-of-three partitioning is that after the leftcenterand right elements are sortedthe partition process doesn' need to examine these elements again the partition can begin at left+ and right- because left and right have in effect already been partitioned we know that left is in the correct partition because it' on the left and it' less than the pivotand right is in the correct place because it' on the right and it' greater than the pivot thusmedian-of-three partitioning not only avoids ( performance for already sorted datait also allows us to speed up the inner loops of the partitioning algorithm and reduce slightly the number of items that must be partitioned the quicksort java program listing shows the quicksort java programwhich incorporates median-of-three partitioning we use separate methodmedianof ()to sort the leftcenterand right