|
4 | 4 | A Maze is given as N*N binary matrix of blocks where source block is the upper left most block i.e., maze[0][0] and destination block is lower rightmost block i.e., maze[N-1][N-1]. A rat starts from source and has to reach the destination. The rat can move only in two directions: forward and down.
|
5 | 5 | In the maze matrix, 0 means the block is a dead end and 1 means the block can be used in the path from source to destination. Note that this is a simple version of the typical Maze problem. For example, a more complex version can be that the rat can move in 4 directions and a more complex version can be with a limited number of moves.
|
6 | 6 |
|
7 | | -Algorithm: |
| 7 | +**Algorithm:** |
8 | 8 | If destination is reached
|
9 | 9 | print the solution matrix
|
10 | 10 | Else
|
@@ -37,10 +37,10 @@ The 1 values show the path of rat.
|
37 | 37 | ```
|
38 | 38 |
|
39 | 39 |
|
40 | | -Complexity Analysis: |
| 40 | +### Complexity Analysis: |
41 | 41 |
|
42 | | -Time Complexity: O(2^(n^2)). |
| 42 | +**Time Complexity:** O(2^(n^2)). |
43 | 43 | The recursion can run upperbound 2^(n^2) times.
|
44 | 44 |
|
45 | | -Space Complexity: O(n^2). |
| 45 | +**Space Complexity:** O(n^2). |
46 | 46 | Output matrix is required so an extra space of size n*n is needed.
|
0 commit comments