高级农民
- 积分
- 1166
- 大米
- 颗
- 鳄梨
- 个
- 水井
- 尺
- 蓝莓
- 颗
- 萝卜
- 根
- 小米
- 粒
- 学分
- 个
- 注册时间
- 2014-6-1
- 最后登录
- 1970-1-1
|
能出错的地方实在太多,建议可以先用较小的maze进行debug。
union注意要用root。仔细读题 一步一步来。
这次作业做下来很受鼓舞 加油~!!
(a) How would your algorithm ensure that there is a path between every pair of
cells, but no more than one path between any pair of cells (i.e., no
cycles)?
Because the disjointed sets are utilized, each cell can only be reached through only one path, the DFS is a wise choice then.
(PS: Disjointed sets can use one array to generate multiple trees, and utilize "union" to combine them by considering root, in this case, no duplicate item will be shown in different trees)
(b) How does your algorithm use random numbers to generate a different maze
each time? Specifically, what decision should be made by random numbers
at each recursive invocation of the depth-first search method?
Random number is utilized to choose next wall into consideration randomly, and mark the wall as true (closed) or false (open),so that the maze can be presented randomly. Furthermore, the direction and status of room will be made.
|
|