Hanoi Towers part 1 CS 244 Brent M. Dingle, Ph.D. Game Design and Development Program Department of Mathematics, Statistics, and Computer Science University.

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

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
2.3 Recursion do automated demo of towers of hanoi before class
COSC 2006 Data Structures I Recursion III
Georgia Department of Education. Information Technology Pathways.
Lesson 19 Recursion CS1 -- John Cole1. Recursion 1. (n) The act of cursing again. 2. see recursion 3. The concept of functions which can call themselves.
Representational Choices The Towers of Hanoi Problem.
1 CSCD 300 Data Structures Recursion. 2 Proof by Induction Introduction only - topic will be covered in detail in CS 320 Prove: N   i = N ( N + 1.
Recursive Algorithms Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Recursion Jordi Cortadella Department of Computer Science.
Multiplying and Dividing Decimals by 10, 100, and 1,000
Recursion Part 3 CS221 – 2/27/09. Recursion A function calls itself directly: Test() { … Test(); … }
Assignment Paired Prototyping Some content based on GDC 2006, Gingold and Hecker Brent M. Dingle 2014 Game Design and Development Program Mathematics,
General Data Structures and Algorithms CS 244 Brent M. Dingle, Ph.D. Department of Mathematics, Statistics, and Computer Science University of Wisconsin.
Linked Lists part 2 CS 244 Brent M. Dingle, Ph.D. Game Design and Development Program Department of Mathematics, Statistics, and Computer Science University.
MATHS FOR GENIUS: TOWER OF HANOI Pedro Luis Fernández Martínez.
Review and Prepare for Test 3 CS 244 Brent M. Dingle, Ph.D. Game Design and Development Program Department of Mathematics, Statistics, and Computer Science.
By: Lokman Chan Recursive Algorithm Recursion Definition: A function that is define in terms of itself. Goal: Reduce the solution to.
Big Oh CS 244 Brent M. Dingle, Ph.D. Game Design and Development Program Department of Mathematics, Statistics, and Computer Science University of Wisconsin.
C++ and Ubuntu Linux Review and Practice CS 244 Brent M. Dingle, Ph.D. Game Design and Development Program Department of Mathematics, Statistics, and.
Bubble Sort Data Structures and Algorithms CS 244 Brent M. Dingle, Ph.D. Game Design and Development Program Department of Mathematics, Statistics, and.
Priority Queues, Trees, and Huffman Encoding CS 244 This presentation requires Audio Enabled Brent M. Dingle, Ph.D. Game Design and Development Program.
HelloWorld – GameOver CS 244 – Data Structures and Algorithms Department of Mathematics, Statistics, and Computer Science University of Wisconsin – Stout.
Makefiles, Geany CS 244 Brent M. Dingle, Ph.D. Game Design and Development Program Department of Mathematics, Statistics, and Computer Science University.
Hanoi Towers Big Oh Recursion Data Structures and Algorithms CS 244 Brent M. Dingle, Ph.D. Department of Mathematics, Statistics, and Computer Science.
Searching CS 244 Brent M. Dingle, Ph.D. Game Design and Development Program Department of Mathematics, Statistics, and Computer Science University of Wisconsin.
WELCOME to CS244 Brent M. Dingle, Ph.D Game Design and Development Program Mathematics, Statistics and Computer Science University of Wisconsin -
Priority Queues and Sorting CS 244 Brent M. Dingle, Ph.D. Game Design and Development Program Department of Mathematics, Statistics, and Computer Science.
Linked Lists part 1 CS 244 Brent M. Dingle, Ph.D. Game Design and Development Program Department of Mathematics, Statistics, and Computer Science University.
Merge Sort Data Structures and Algorithms CS 244 Brent M. Dingle, Ph.D. Department of Mathematics, Statistics, and Computer Science University of Wisconsin.
22C:19 Discrete Math Advanced Counting Fall 2010 Sukumar Ghosh.
Quicksort Data Structures and Algorithms CS 244 Brent M. Dingle, Ph.D. Game Design and Development Program Department of Mathematics, Statistics, and Computer.
Pass the Buck Every good programmer is lazy, arrogant, and impatient. In the game “Pass the Buck” you try to do as little work as possible, by making your.
Priority Queues and Heaps Data Structures and Algorithms CS 244 Brent M. Dingle, Ph.D. Department of Mathematics, Statistics, and Computer Science University.
Reading from a file, Sorting, and a little Searching Data Structures and Algorithms CS 244 Brent M. Dingle, Ph.D. Department of Mathematics, Statistics,
Brent M. Dingle Game Design and Development Program Mathematics, Statistics and Computer Science University of Wisconsin - Stout.
UNIT 17 Recursion: Towers of Hanoi.
CMPF144 FUNDAMENTALS OF COMPUTING THEORY Module 9: The Tower of Hanoi.
1 Recursion Recursive function: a function that calls itself (directly or indirectly). Recursion is often a good alternative to iteration (loops). Its.
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.
Aumm-e-hani munir Maria umer Rakhshanda batool Faiza.
Take the Test Data Structures and Algorithms CS 244 Brent M. Dingle, Ph.D. Department of Mathematics, Statistics, and Computer Science University of Wisconsin.
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.
1 ADT Implementation: Recursion, Algorithm Analysis Chapter 10.
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.
Recursion CS 244 Brent M. Dingle, Ph.D. Game Design and Development Program Department of Mathematics, Statistics, and Computer Science University of Wisconsin.
Tower of Hanoi problem: Move the pile of rings from one peg to another
Recursion.
Pramada Ramachandran, Assistant Professor, Department of Mathematics,
COMP 51 Week Fourteen Recursion.
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.
Recursive Thinking Chapter 9 introduces the technique of recursive programming. As you have seen, recursive programming involves spotting smaller occurrences.
More on Merge Sort CS 244 This presentation is not given in class
Jordi Cortadella Department of Computer Science
Tower of Hanoi problem: Move the pile of rings from one peg to another
The Hanoi Tower Problem
Review and Prepare for Test 2
Tower of Hanoi Algorithm
Tower of Hanoi Txt: 10.4 and p. 478 & SOL: DM.10
Dr. Sampath Jayarathna Cal Poly Pomona
Running Time Exercises
Tower of Hanoi problem: Move the pile of rings from one peg to another
Data Structures and Algorithms CS 244
Presentation transcript:

Hanoi Towers part 1 CS 244 Brent M. Dingle, Ph.D. Game Design and Development Program Department of Mathematics, Statistics, and Computer Science University of Wisconsin – Stout 2014

Towers of Hanoi 7 moves

Human Way while true: if n is odd: move disk1 one peg left (first peg wraps around to last peg) else: move disk1 one peg right (last peg wraps around to first peg) if done: break else: make the only legal move not involving disk1

Computer Way Tower of Hanoi & Big Oh Pseudocode : FUNCTION MoveTower(n, source,dest, spare): IF n == 1, THEN: move disk 1 from source to dest //base case ELSE: MoveTower(n - 1, source, spare, dest) // Step 1 move disk n from source to dest // Step 2 MoveTower(n - 1, spare, dest, source) // Step 3 END IF aside: 1 is smallest disk and n is the largest disk How did we get this code? Think on it =) See also Homework 5

Free Play – Things to Work On Homework 4 Homework 5

The End Or is it?