Question
Maze problem: A binary matrix is given say B, the task is to find a sequence of moves from a given initial location (X0, Y0)
Maze problem: A binary matrix is given say B, the task is to find a sequence of moves from a given initial location (X0, Y0) in the matrix, to a final location (Xn, Yn) explicitly using stack. Ex: 0 0 1 0 0 1 1 1 0 1 1 1 1 1 0 1 0 0 1 0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 0 1 0 0 1 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 1 0 0 0 1 0 1 1 0 0 The initial position X0, Y0 has 1 as the element. A move can be made to a location; only if there is 1 in the neighboring co-ordinate (only 4- neighbors are considered ignoring diagonal neighbors). In the above example from initial location (0,2) the possible move is (1,2). From (1, 2) the possible moves are (0,2), (1,3), (1,1) and (2,2). So the expected output for the input (0,2) as start and (7,4) as the destination is, a sequence (0,2)(1,2)(2,2)(3,2)(3,3)(3,4)(3,5)(3,6)(4,6)(5,6)(6,6)(6,5) (7,5)(7,4). There can be similar other paths.
Maze problem: A binary matrix is given say B, the task is to find a sequence of moves from a given initial location (Xo, Yo) in the matrix, to a final location (Xn, Yn) explicitly using stack. Ex: 0 0 1 0 1 1 1 1 0 1 0 0 1 0 0 0 0 1 Intial Location (Xo, Yo)-(0, 2) 0 0 0 1 0 0 1 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0 1 0 (1 Final Location (Xn, %)=(7, 4) 0 The initial position Xo, Yo has 1 as the element. A move can be made to a lpcation; only if there is 1 in the neighboring co-ordinate (only 4- neighbors are considered ignoring diagonal neighbors). In the above example from initial location (0,2) the possible move is (1,2). From (1, 2) the possible moves are (0,2), (1,3), (1,1) and (2,2). So the expected output for the input (0,2) as start and (7,4) as the destination is, a sequence There can be similar other pathsStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started