COP 3530
Assignment 5
Due: 11
th
October, 2010
In this problem you will solve the “Rat in a maze problem” (Lecture 12), using Stacks and
Queues.
The maze is given as a 2D array, where '0's are squares the rat can move to; '1's represent the
squares where the rat cannot move to. The coordinates of the square at the top left corner are
(0,0). The coordinates of the square ate the bottom right corner are (14,12). The positive direction
of x axis is to the right, and the positive direction of y axis is down.
You have to implement these three methods:
searchStack(int fromX,int fromY,int toX,int toY) ,
searchQueue(int fromX,int fromY,int toX,int toY) ,
searchStackSmart(int fromX,int fromY,int toX,int toY)
In all above methods, the problem is to find a path from (fromX, fromY) point to (toX, toY).
Each method has its own strategy:
searchStack:
A rat that always attempts to move in a specific order: right, down, left and up.
This method should be implemented using a stack.
searchQueue:
On a given square, the rat reproduces, and up to four rats take one step away from
the current square, each rat in a different direction. Each of these rats will choose one direction:
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Summer '08
 Davis
 Algorithms, Cartesian Coordinate System, Data Structures, Leftwing politics, int toX

Click to edit the document details