Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

5. We consider the \"Towers of Hanoi\" problem with n = 7 disks of different siz

ID: 3599000 • Letter: 5

Question

5. We consider the "Towers of Hanoi" problem with n = 7 disks of different sizes and 3 pegs (or towers, labeled A, B, C) is described on the Wikipedia page http://en.wikipedia.org/wiki/Towers of Hanoi. Write a recursive MATLAB program to determine the sequence of moves to bring all disks to peg C starting with all disks at peg A, given the fact that (a) only one disk can be moved at a time and b) a larger disk cannot be on top of a smaller disk After each move record the position for each disk by the peg it is located at. The starting position is AAAAAAA (from smallest = top on the left to largest = botton on the right), and the last position is CCcccCC. Determine the sequence of moves (i.e. a sequence of 7-letter

Explanation / Answer

Ans 1) Tower of Hanoi is very important mathmatical puzzle. Tower of Hanoi is also a game in which 3 sticks are there and the number of plates are there and these plates can be onto any of the stick

The main objective of the this game or this puzzle is to move all plates from one stick to the another stick obeying the rules which are as follows:

1) only one plate can be moved at a time

2) Taking of upper plate from the stack and placing it on the top of the another stick

3) A larger disk cannot be on top of a smaller plate.

Using 3 plates, puzzles can be solved only in the 7 moves.The minimum number of moves required to solve the puzzle is 2^n-1 where 'n' is the number of plates.

MATLAB programm to solve this puzzle is:

function towerofhanoi (n,x,y,z)

if (n~=0)

towerofhanoi(n-1,x,y,z);

disp(sprintf('move plate %d from stick %d to stick %d',[n,x,z]));

towerofhanoi(n-1,y,z,x);

end

end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote