algorithm (28.218.81608.81609.81613.9493.81899.81849.81917.82000)

40. This algorithm uses the following terminology: The peg on which the rings start is called the initial peg, the peg to which the rings are to be moved is called the destination peg, the third peg is called the auxiliary peg, and the number of rings to be moved is represented by N. procedure Towers (Initial, Destination, Auxiliary, N) if (N equals 1) then (Move the top ring from the Initial peg to the Destination peg) else (Apply Towers to move N-1 rings from the current Initial peg to the current Auxiliary peg, Move the top ring from the Initial peg to the Destination peg, Apply Towers to move N-1 rings from the current Auxiliary peg to the current Destination peg) 41. The solution is almost totally given in the problem. while (the rings are not all on the destination peg) do (move the largest numbered ring that can be moved) 42. Using a loop structure: Day โ† 1 Pay โ† 1 while (Day is less than 31) do (print the value assigned to Pay, Pay โ† Pay times 2, Day โ† Day + 1) Using recursion: Apply the procedure ComputePay with initial values of Day and Pay being 1. procedure ComputePay (Pay, Day) Print the value assigned to Pay, Apply ComputePay using Day + 1 for the new value of Day and Pay + Pay for the new value of Pay)

group status

๐Ÿ‘ค group joined: 0 โณ group pending: 0 ๐Ÿšซ group blocked: 0

Sub Domains (0)