chap listsstacksand queues static void toh(int npole startpole goalpole temp/make stack just big enough stack new astack( * + ) push(new tohobj(operation tohnstartgoaltemp))while ( length( tohobj it pop()/get next task if (it op =operation move/do move move(it startit goal)else if (it num /imitate toh recursive /solution (in reverses push(new tohobj(operation tohit num- it tempit goalit start)) push(new tohobj(operation moveit startit goal))/ move to do push(new tohobj(operation tohit num- it startit tempit goal))we first define an enumerated type called tohopwith two values move and tohto indicate calls to the move function and recursive calls to tohrespectively note that an array-based stack is usedbecause we know that the stack will need to store exactly elements the new version of toh begins by placing on the stack description of the initial problem of rings the rest of the function is simply while loop that pops the stack and executes the appropriate operation in the case of toh operation (for )we store on the stack representations for the three operations executed by the recursive version howeverthese operations must be placed on the stack in reverse orderso that they will be popped off in the correct order some "naturally recursiveapplications lend themselves to efficient implementation with stackbecause the amount of information needed to describe subproblem is small for examplesection discusses stack-based implementation for quicksort queues like the stackthe queue is list-like structure that provides restricted access to its elements queue elements may only be inserted at the back (called an enqueue