chap mathematical preliminaries ( (bfigure towers of hanoi example (athe initial conditions for problem with six rings (ba necessary intermediate step on the road to solution how can you solve this problemit is easy if you don' think too hard about the details insteadconsider that all rings are to be moved from pole to pole it is not possible to do this without first moving the bottom (largestring to pole to do thatpole must be emptyand only the bottom ring can be on pole the remaining rings must be stacked up in order on pole as shown in figure how can you do thisassume that function is available to solve the problem of moving the top rings from pole to pole then move the bottom ring from pole to pole finallyagain use function to move the remaining rings from pole to pole in both cases"function xis simply the towers of hanoi function called on smaller version of the problem the secret to success is relying on the towers of hanoi algorithm to do the work for you you need not be concerned about the gory details of how the towers of hanoi subproblem will be solved that will take care of itself provided that two things are done firstthere must be base case (what to do if there is only one ringso that the recursive process will not go on forever secondthe recursive call to towers of hanoi can only be used to solve smaller problemand then only one of the proper form (one that meets the original definition for the towers of hanoi problemassuming appropriate renaming of the poleshere is java implementation for the recursive towers of hanoi algorithm function move(startgoaltakes the top ring from pole start and moves it to pole goal if the move function were to print the values of its parametersthen the result of calling toh would be list of ring-moving instructions that solves the problem