【发布时间】:2020-02-02 12:04:13
【问题描述】:
我正在努力计算这段代码中的时间复杂度。 目前只能写简单的代码... 只是想尝试复杂的!
public static int PATHWAY = 0;
public static int WALL = 1;
public static int MARKED = 2;
public static boolean find(int x, int y) {
if(x == 7 && y == 7) return true;
maze[x][y] = MARKED;
if(x != 0 && maze[x-1][y] == PATHWAY && find(x-1, y)) return true;
if(y != 0 && maze[x][y-1] == PATHWAY && find(x, y-1)) return true;
if(x != 7 && maze[x+1][y] == PATHWAY && find(x+1, y)) return true;
if(y != 7 && maze[x][y+1] == PATHWAY && find(x, y+1)) return true;
return false;
}
【问题讨论】:
-
我错了还是它永远不会收敛?
标签: java time complexity-theory