advanced sorting as you single-step through the algorithmyou'll notice that the explanation we gave in the preceding discussion is slightly simplified the sequence for the -sort is not actually ( , , )( , , )( , )and ( , insteadthe first two elements of each group of three are sorted firstthen the first two elements of the second groupand so on once the first two elements of all the groups are sortedthe algorithm returns and sorts three-element groups the actual sequence is ( , )( , )( , )( , )( , , )( , , it might seem more obvious for the algorithm to -sort each complete subarray first--( , )( , , )( , )( , , )( , )( , )--but the algorithm handles the array indices more efficiently using the first scheme the shellsort is actually not very efficient with only itemsmaking almost as many swaps and comparisons as the insertion sort howeverwith bars the improvement becomes significant it' instructive to run the workshop applet starting with inversely sorted bars (remember thatas in the first press of new creates random sequence of barswhile the second press creates an inversely sorted sequence figure shows how the bars look after the first passwhen the array has been completely -sorted figure shows the situation after the next passwhen it is -sorted with each new value of hthe array becomes more nearly sorted figure after the -sort why is the shellsort so much faster than the insertion sorton which it' basedwhen is largethe number of items per pass is smalland items move long distances this is very efficient as grows smallerthe number of items per pass increasesbut the items are already closer to their final sorted positionswhich is