160 likes | 263 Views
Representational Choices. The Towers of Hanoi Problem. We will consider five Representational Choice for the Towers of Hanoi Problem. Graphical Extensional (Table) Extensional (Descriptive) Recurrence Relation (intensional) Pseudo-code (intensional).
E N D
Representational Choices The Towers of Hanoi Problem
We will consider five Representational Choice for the Towers of Hanoi Problem • Graphical • Extensional (Table) • Extensional (Descriptive) • Recurrence Relation (intensional) • Pseudo-code (intensional)
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.
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.