Download presentation
Presentation is loading. Please wait.
1
Representational Choices The Towers of Hanoi Problem
2
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)
3
1.Graphical Representation (Start State)
4
Graphical Representation (Goal State)
5
Graphical Representation (Step 1)
6
Graphical Representation (Step Two)
7
Graphical Representation (Step 3)
8
Graphical Representation (Step 4: Isolate “Mr. Big”)
9
Graphical Representation (Step 5: Unravel from Peg B)
10
Graphical Representation (Step 6: Assemble on Peg C)
11
Graphical Representation (Step 7: Finish Assembly on Peg C)
12
Table Representation No. Disks Moves to Temp Peg Moves from Temp to Goal “Mr. Big” to Goal Total Number Moves 10011 21113 33317 477115 5 131 6 163 7 1127 8 1255 9 1511 101023 12047
13
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 (15 + 15 + 1) for 5 disks, 63 moves (31 + 31 + 1) for 6 disks, etc.
14
Representational Choices (4 Recurrence Relation (Intensional) T(1) = 1 T(N) = 2 T (N-1) + 1 Which has solution T(N) = 2^N -1.
15
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)
16
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.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.