Lance Danzy Melinda Katanbafnezhad. The “A Mazing Problem” is a classical experiment from psychology where scientists carefully observe a rat going through.

Slides:



Advertisements
Similar presentations
AI Pathfinding Representing the Search Space
Advertisements

© 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of CHAPTER 7: Recursion Java Software Structures: Designing and Using.
Data-Flow Analysis Framework Domain – What kind of solution is the analysis looking for? Ex. Variables have not yet been defined – Algorithm assigns a.
Depth-First Search1 Part-H2 Depth-First Search DB A C E.
Types of Algorithms.
Jessica Pearlman, Melissa Ackley, and Kate Stansfield
Searching Algorithms Finding what you are looking for.
Graphs By JJ Shepherd. Introduction Graphs are simply trees with looser restrictions – You can have cycles Historically hard to deal with in computers.
Announcements Assignment #4 is due tonight. Last lab program is going to be assigned this Wednesday. ◦ A backtracking problem.
Loops (Part 1) Computer Science Erwin High School Fall 2014.
Recursion Topics: Definition of Recursion Numeric Recursion Non-Numeric Recursion Inefficiency of Recursion.
Backtracking COP Backtracking  Backtracking is a technique used to solve problems with a large search space, by systematically trying and eliminating.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Graphs.
Kevyn Bollinger Eric Gonsalves Ben Henry James Marsland.
Chapter 10 Recursion. Copyright © 2005 Pearson Addison-Wesley. All rights reserved Chapter Objectives Explain the underlying concepts of recursion.
Depth-first search COMP171 Fall Graph / Slide 2 Depth-First Search (DFS) * DFS is another popular graph search strategy n Idea is similar to pre-order.
Routing 2 Outline –Maze Routing –Line Probe Routing –Channel Routing Goal –Understand maze routing –Understand line probe routing.
CHAPTER 10 Recursion. 2 Recursive Thinking Recursion is a programming technique in which a method can call itself to solve a problem A recursive definition.
The Power of Calling a Method from Itself Svetlin Nakov Telerik Corporation
Problem Solving and Mazes
Recursion. Definition Recursion is a function calling on itself over and over until reaching an end state. One such example is factorial. 10! = 10 * 9.
Representing and Using Graphs
INTRODUCTION TO BINARY TREES P SORTING  Review of Linear Search: –again, begin with first element and search through list until finding element,
CSE 143 Lecture 17 More Recursive Backtracking reading: "Appendix R" on course web site slides created by Marty Stepp and Hélène Martin
Lists. Container Classes Many applications in Computer Science require the storage of information for collections of entities e.g. a student registration.
Two Dimensional Arrays
State-Space Searches. 2 State spaces A state space consists of A (possibly infinite) set of states The start state represents the initial problem Each.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Graphs.
Recursion When to use it and when not to use it. Basics of Recursion Recursion uses a method Recursion uses a method Within that method a call is made.
“Planning is bringing the future into the present so that you can do something about it now.” – Alan Lakein Thought for the Day.
Announcements This Wednesday, Class and Labs are cancelled! The last lab is due this Wednesday … how many people are planning on doing it? Finally posted.
COMPUTER PROGRAMMING. Iteration structures (loops) There may be a situation when you need to execute a block of code several number of times. In general,
Two Dimensional Arrays. Two-dimensional Arrays Declaration: int matrix[4][11]; 4 x 11 rows columns
CHAPTER 4 RECURSION. BASICALLY, A METHOD IS RECURSIVE IF IT INCLUDES A CALL TO ITSELF.
CPS Backtracking, Search, Heuristics l Many problems require an approach similar to solving a maze  Certain mazes can be solved using the “right-hand”
Algorithms April-May 2013 Dr. Youn-Hee Han The Project for the Establishing the Korea ㅡ Vietnam College of Technology in Bac Giang.
1 Recursion Recursion is a powerful programming technique that provides elegant solutions to certain problems. Chapter 11 focuses on explaining the underlying.
W1-1 University of Washington Computer Programming I Recursion © 2000 UW CSE.
Kruse/Ryba ch051 Object Oriented Data Structures Recursion Introduction to Recursion Principles of Recursion Backtracking: Postponing the Work Tree-Structured.
Recursion Chapter 17 Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013.
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.
Lecture 7 – Repetition (Loop) FTMK, UTeM – Sem /2014.
Chapter 15 Running Time Analysis. Topics Orders of Magnitude and Big-Oh Notation Running Time Analysis of Algorithms –Counting Statements –Evaluating.
Comp1004: Loops and Arrays I Whiles, For and Arrays[]
Backtracking, Search, Heuristics
Section 4.4 Counting Blobs
Depth First Seach: Output Fix
Recursive Exploration II
Data Structures and Algorithms
Fundamentals of Programming II Backtracking with Stacks
10.2 Implementation and Execution of Recursive Code
Structural testing, Path Testing
Solving Mazes Troy Mahon.
More Recursion.
Java Software Structures: John Lewis & Joseph Chase
7.4 Problem Solving with Recursion
Chapter 12 Recursion (methods calling themselves)
Lab 07 – 3D Maze.
Search,Sort,Recursion.
Graphs Part 2 Adjacency Matrix
adapted from Recursive Backtracking by Mike Scott, UT Austin
Search,Sort,Recursion.
Algorithms: Design and Analysis
Recursion.
IPC144 Introduction to Programming Using C Week 4 – Lesson 2
Functions and Recursion
Backtracking, Search, Heuristics
Module 8 – Searching & Sorting Algorithms
Presentation transcript:

Lance Danzy Melinda Katanbafnezhad

The “A Mazing Problem” is a classical experiment from psychology where scientists carefully observe a rat going through a maze. This experiment is performed repeatedly until the rat goes through the maze without going down a single dead end path. This demonstrates the rat’s learning curve. The computer program that does the same thing is not any smarter than the rat on its first try through, but the computer can remember the mistakes it made. The second time it runs through the maze it should go all the way through without going down dead ends. With a computer’s memory, and the right algorithm going through a maze is simple.

 Using a recursive method every time a spot is visited, the method checks all surrounding spots for a path and marks what’s already been visited. If it reads in a point that is not a wall or marked as visited, it moves to that point. It will continuously do this until it has reached a mark indicating the end of the maze. If it reaches a dead end, it does not mark the point.

 public bool labelPath(int startRow, int startCol) { //from the starting location specified by the parameters to the finis //is point in the maze boundaries if (startRow = rows || startCol = cols) { return false; } if (theMaze[startRow, startCol] == 'F') { // we are at the end of the maze return true; } // is point a valid path? if (theMaze[startRow, startCol] == ' ') { // mark this path just in case it works from here theMaze[startRow, startCol] = '-'; // find if there is a route past here  if (labelPath(startRow + 1, startCol) || labelPath(startRow - 1, startCol) || labelPath(startRow, startCol + 1) || labelPath(startRow, startCol - 1)) { // this is a good path! return true; } else { // this is not a good path - unmark it. theMaze[startRow, startCol] = ' '; } } return false; }

Wall Follower The best known rule for traversing mazes, also known as the left hand rule or the right hand rule. This method always keeps the wall on one side of the navigator, by doing this the navigator is guaranteed not to get lost and will reach an exit if there is one.

Dead-end Filling This method looks at the entire maze once, finds all the dead-ends and then fills in the path from each dead end until there is a continuous path from start to finish.

Similar to how a GPS finds the shortest route to a destination, our algorithm determines the shortest path to the end of a maze, although a GPS may not necessarily use this algorithm and knows your location. If you ever find yourself trapped inside of a maze/labyrinth we recommend that you use a wall following method to escape, not recursion.

  Horowitz, E., Sahni, S., & Mehta, D. (1995). Fundamentals of Data Structures in C++. New York: W. H. Freeman & Co.  