for each mergethe maximum number of comparisons is one less than the number of items adding these figures for all the merges gives us total of the minimum number of comparisons is always half the number of items being mergedand adding these figures for all the merges results in comparisons similar arithmetic results in the comparisons columns for table the actual number of comparisons to sort specific array depends on how the data is arrangedbut it will be somewhere between the maximum and minimum values eliminating recursion some algorithms lend themselves to recursive approachsome don' as we've seenthe recursive triangle(and factorial(methods can be implemented more efficiently using simple loop howevervarious divide-and-conquer algorithmssuch as mergesortwork very well as recursive routine often an algorithm is easy to conceptualize as recursive methodbut in practice the recursive approach proves to be inefficient in such casesit' useful to transform the recursive approach into nonrecursive approach such transformation can often make use of stack recursion and stacks there is close relationship between recursion and stacks in factmost compilers implement recursion by using stacks as we notedwhen method is calledthey push the arguments to the method and the return address (where control will go when the method returnson the stackand then transfer control to the method when the method returnsthey pop these values off the stack the arguments disappearand control returns to the return address simulating recursive method in this section we'll demonstrate how any recursive solution can be transformed into stack-based solution remember the recursive triangle(method from the first section in this here it is againint triangle(int nif( == return else returnn triangle( - )we're going to break this algorithm down into its individual operationsmaking each operation one case in switch statement (you can perform similar decomposition using goto statements in +and some other languagesbut java doesn' support goto the switch statement is enclosed in method called step(each call to step(causes one case section within the switch to be executed calling step(repeatedly will eventually execute all the code in the algorithm