Skip to main content
ICT
Lesson AB24 - Recursive Array Programming
 
Main Previous Next
Title Page >  
Summary >  
Lesson A1 >  
Lesson A2 >  
Lesson A3 >  
Lesson A4 >  
Lesson A5 >  
Lesson A6 >  
Lesson A7 >  
Lesson A8 >  
Lesson A9 >  
Lesson A10 >  
Lesson A11 >  
Lesson A12 >  
Lesson A13 >  
Lesson A14 >  
Lesson A15 >  
Lesson A16 >  
Lesson A17 >  
Lesson A18 >  
Lesson A19 >  
Lesson A20 >  
Lesson A21 >  
Lesson A22 >  
Lesson AB23 >  
Lesson AB24 >  
Lesson AB25 >  
Lesson AB26 >  
Lesson AB27 >  
Lesson AB28 >  
Lesson AB29 >  
Lesson AB30 >  
Lesson AB31 >  
Lesson AB32 >  
Lesson AB33 >  
Vocabulary >  
 

A. Defining the Maze Problem page 3 of 7

  1. The maze will be defined as a 2-D grid of asterisks (marking walls) and blanks (marking potential paths). The size of the grid will be 12 x 12 and the starting location will be at 6, 6.

  2. The data structure for this problem will be a 2-dimensional array of char. The array will be declared as a 13 x 13 grid so that we can use locations 1..12 by 1..12. Row 0 and column 0 will not be used in the data structure.

  3. The initial grid is stored as a text file and will be loaded into the array.

    (Here is a copy of the mazeData.txt file)

  4. The solution is a backtracking algorithm involving a series of trial and error attempts. A potential path out of the maze will be traced with a !, with moves limited to horizontal or vertical directions. If a dead-end is encountered, back up and try a different direction.

  5. We will be at an exit point if we arrive at row 1 or MAXROW, or at column 1 or MAXCOL.

 

Main Previous Next
Contact
 © ICT 2006, All Rights Reserved.