advanced sorting if an array holds , itemsit could be -sorted -sorted -sorted -sorted -sortedand finally -sorted the shellsort is hard to analyzebut runs in approximately ( *(logn) time this is much faster than the ( algorithms like insertion sortbut slower than the ( *lognalgorithms like quicksort to partition an array is to divide it into two subarraysone of which holds items with key values less than specified valuewhile the other holds items with keys greater than or equal to this value the pivot value is the value that determines into which group an item will go during partitioning items smaller than the pivot value go in the left grouplarger items go in the right group in the partitioning algorithmtwo array indiceseach in its own while loopstart at opposite ends of the array and step toward each otherlooking for items that need to be swapped when an index finds an item that needs to be swappedits while loop exits when both while loops exitthe items are swapped when both while loops exitand the indices have met or passed each otherthe partition is complete partitioning operates in linear (ntimemaking plus or comparisons and fewer than / swaps the partitioning algorithm may require extra tests in its inner while loops to prevent the indices running off the ends of the array quicksort partitions an array and then calls itself twice recursively to sort the two resulting subarrays subarrays of one element are already sortedthis can be base case for quicksort the pivot value for partition in quicksort is the key value of specific itemcalled the pivot in simple version of quicksortthe pivot can always be the item at the right end of the subarray during the partition the pivot is placed out of the way on the rightand is not involved in the partitioning process later the pivot is swapped againinto the space between the two partitions this is its final sorted position