Representational Choices The Towers of Hanoi Problem
We will consider five Representational Choice for the Towers of Hanoi Problem 1.Graphical 2.Extensional (Table) 3.Extensional (Descriptive) 4.Recurrence Relation (intensional) 5.Pseudo-code (intensional)
1.Graphical Representation (Start State)
Graphical Representation (Goal State)
Graphical Representation (Step 1)
Graphical Representation (Step Two)
Graphical Representation (Step 3)
Graphical Representation (Step 4: Isolate “Mr. Big”)
Graphical Representation (Step 5: Unravel from Peg B)
Graphical Representation (Step 6: Assemble on Peg C)
Graphical Representation (Step 7: Finish Assembly on Peg C)
Table Representation No. Disks Moves to Temp Peg Moves from Temp to Goal “Mr. Big” to Goal Total Number Moves
Extensional (Descriptive) Solution Attachment Towers Image 2: Extensional Solution For any number of disks, N, if the main goal is to move those N disks from Peg A to Peg C, then you can complete the following steps: Move N-1 disks to an intermediary peg (B), which takes 2(N-1) – 1 moves (e.g., for three disks, move two disks (2^2 – 1 moves = 3 moves) to peg B). Move the biggest disk from Peg A to Peg C (the Goal). Move the N-1 disks from Peg B to Peg C (the Goal, which takes three more moves). In total, you need 7 moves for 3 discs, 15 moves for 4 disks, 31 moves ( ) for 5 disks, 63 moves ( ) for 6 disks, etc.
Representational Choices (4 Recurrence Relation (Intensional) T(1) = 1 T(N) = 2 T (N-1) + 1 Which has solution T(N) = 2^N -1.
Representational Choices: Pseudo- Code (intensional, RECURSIVE) n is the number of disks Start is the start peg int is the intermediate peg Dest is the goal or destination peg TOH (n, Start, Int, Dest) If n = 1 then move disk from Start to Dest Else TOH(n-1, Start, Dest, Int) TOH(1, Start, Int, Dest) TOH(n-1, Int, Start, Dest)
SUMMARY Note that each of these intentional representations is also an example of problem reduction. A problem that seemed large and complex has been broken down into smaller, manageable problems whose solution can be carried out and is understandable to the problem- solver.