Representational Choices The Towers of Hanoi Problem.

Slides:



Advertisements
Similar presentations
Tower of Hanoi Tower of Hanoi is a mathematical puzzle invented by a French Mathematician Edouard Lucas in The game starts by having few discs stacked.
Advertisements

The Towers of Hanoi or Apocalypse When?.
CS1010: Programming Methodology
Chapter Objectives To learn about recursive data structures and recursive methods for a LinkedList class To understand how to use recursion to solve the.
The Algorithmic problems?
More Recursion: Permutations and Towers of Hanoi COP 3502.
Towers of Hanoi
COSO 1030 Section 4 Recursion. What is about Towers of Hanoi Divide and Conquer Strategy Recursion and Induction Thinking Recursively Recursion Pitfalls.
Recurrences. What is a Recurrence Relation? A system of equations giving the value of a function from numbers to numbers in terms of the value of the.
Recursion. Idea: Some problems can be broken down into smaller versions of the same problem Example: n! 1*2*3*…*(n-1)*n n*factorial of (n-1)
1 CSE1301 Computer Programming Lecture 28 Recursion (Part 2)
Chapter Day 25. © 2007 Pearson Addison-Wesley. All rights reserved Agenda Day 25 Problem set 5 Posted (Last one)  Due Dec 8 Friday Capstones Schedule.
© 2006 Pearson Addison-Wesley. All rights reserved6-1 More on Recursion.
Chapter 10 Recursion. Copyright © 2005 Pearson Addison-Wesley. All rights reserved Chapter Objectives Explain the underlying concepts of recursion.
FIT FIT1002 Computer Programming Unit 20 Recursion.
Recursion!. Question Stephen King’s books J. R. R. Tolkien’s books Recursion Do they have something in common?
ELC 310 Day 24. © 2004 Pearson Addison-Wesley. All rights reserved11-2 Agenda Questions? Problem set 5 Parts A Corrected  Good results Problem set 5.
Prof. Amr Goneid, AUC1 Analysis & Design of Algorithms (CSCE 321) Prof. Amr Goneid Department of Computer Science, AUC Part 5. Recursive Algorithms.
Chapter 11 Recursion. © 2004 Pearson Addison-Wesley. All rights reserved11-2 Recursion Recursion is a fundamental programming technique that can provide.
Algorithmic Foundations COMP108 COMP108 Algorithmic Foundations Divide and Conquer Prudence Wong.
CS Final Project 2010 Rohan Paramesh. The Programs  Implementing 3 programs each in C# and Python  Student Scheduler  Assigns courses and students,
Chapter 8 Recursion Modified.
Chapter 4 Recursion. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.1-2 Chapter Objectives Explain the underlying concepts of recursion.
Recursion Part 3 CS221 – 2/27/09. Recursion A function calls itself directly: Test() { … Test(); … }
CHAPTER 4 RECURSION. BASICALLY, A METHOD IS RECURSIVE IF IT INCLUDES A CALL TO ITSELF.
Chapter 5 Recursion. Basically, a method is recursive if it includes a call to itself.
Chapter 6.1: Recurrence Relations Discrete Mathematical Structures: Theory and Applications.
Hanoi Towers Big Oh Recursion Data Structures and Algorithms CS 244 Brent M. Dingle, Ph.D. Department of Mathematics, Statistics, and Computer Science.
Recursive Algorithms A recursive algorithm calls itself to do part of its work The “call to itself” must be on a smaller problem than the one originally.
22C:19 Discrete Math Advanced Counting Fall 2010 Sukumar Ghosh.
1 Recursion Recursion is a powerful programming technique that provides elegant solutions to certain problems. Chapter 11 focuses on explaining the underlying.
1 Examples of Recursion Instructor: Mainak Chaudhuri
COMP 170 L2 L11: Recursion, Recurrence, and Induction l Objective n Recursion  A problem solving technique that reduces big problems into smaller ones.
Algorithmic Foundations COMP108 COMP108 Algorithmic Foundations Divide and Conquer Prudence Wong
TOWERS OF HANOI. : If n = 1, move disk 1 from pole 'A' to pole 'B'. else: 1.First, move n-1 disks from pole 'A' to pole 'C', using pole 'B' as.
UNIT 17 Recursion: Towers of Hanoi.
CMPF144 FUNDAMENTALS OF COMPUTING THEORY Module 9: The Tower of Hanoi.
Recursion Chapter What is recursion? Recursion occurs when a method calls itself, either directly or indirectly. Used to solve difficult, repetitive.
Hanoi Towers part 1 CS 244 Brent M. Dingle, Ph.D. Game Design and Development Program Department of Mathematics, Statistics, and Computer Science University.
1 In this puzzle, the player begins with n disks of decreasing diameter placed one on top of the other on one of three pegs of the game board. The player.
Recursion by Ender Ozcan. Recursion in computing Recursion in computer programming defines a function in terms of itself. Recursion in computer programming.
Aumm-e-hani munir Maria umer Rakhshanda batool Faiza.
1 Towers of Hanoi Three pegs, one with n disks of decreasing diameter; two other pegs are empty Task: move all disks to the third peg under the following.
Lecture 11 Recursion. A recursive function is a function that calls itself either directly, or indirectly through another function; it is an alternative.
1 Data Structures CSCI 132, Spring 2016 Notes 16 Tail Recursion.
Recursion To understand recursion, you first have to understand recursion.
Tower of Hanoi problem: Move the pile of rings from one peg to another
Recursion.
COMP 51 Week Fourteen Recursion.
Recursion.
COMP108 Algorithmic Foundations Divide and Conquer
COMP108 Algorithmic Foundations Divide and Conquer
Recursion &Faster Sorting
Recursive Thinking Chapter 9 introduces the technique of recursive programming. As you have seen, recursive programming involves spotting smaller occurrences.
More Recursion.
Java Software Structures: John Lewis & Joseph Chase
Recursive Thinking Chapter 9 introduces the technique of recursive programming. As you have seen, recursive programming involves spotting smaller occurrences.
Data Structures & Algorithms
יסודות מבני נתונים תרגול 3: נוסחאות נסיגה (recurrences)
Tower of Hanoi problem: Move the pile of rings from one peg to another
The Hanoi Tower Problem
Chapter 11 Recursion.
Tower of Hanoi Algorithm
11 Recursion Software Solutions Lewis & Loftus java 5TH EDITION
Tower of Hanoi Txt: 10.4 and p. 478 & SOL: DM.10
Recursion.
Tower of Hanoi problem: Move the pile of rings from one peg to another
Java Software Solutions Foundations of Program Design Sixth Edition
Tower of Hanoi Problem Laboratory Experiment #1 Eltayeb Abuelyaman
Presentation transcript:

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.