/end class stacktriangle app here two short while loops in the stacktriangle(method substitute for the entire step(method of the stacktriangle java program of coursein this program you can see by inspection that you can eliminate the stack entirely and use simple loop howeverin more complicated algorithms the stack must remain often you'll need to experiment to see whether recursive methoda stack-based approachor simple loop is the most efficient (or practicalway to handle particular situation part iii list advanced sorting binary trees red-black trees advanced sorting overview we discussed simple sorting in the sorts described there--the bubbleselectionand insertion sorts--are easy to implement but are rather slow in we described the mergesort it runs much faster than the simple sortsbut requires twice as much space as the original arraythis is often serious drawback this covers two advanced approaches to sortingshellsort and quicksort these sorts both operate much faster than the simple sortsthe shellsort in about ( *(logntimeand quicksort in ( *logntimewhich is the fastest time for general-purpose sorts neither of these sorts requires large amount of extra spaceas mergesort does the shellsort is almost as easy to implement as mergesortwhile quicksort is the fastest of all the general-purpose sorts we'll examine the shellsort first quicksort is based on the idea of partitioningso we'll then examine partitioning separatelybefore examining quicksort itself shellsort the shellsort is named for donald shellthe computer scientist who discovered it in it' based on the insertion sort but adds new feature that dramatically improves the insertion sort' performance the shellsort is good for medium-sized arraysperhaps up to few thousand itemsdepending on the particular implementation (howeversee the cautionary notes in about how much data can be handled by particular algorithm it' not quite