楼主: 逃亡~
跳转到指定楼层
上一主题 下一主题
收起左侧

uc berkeley CS 61B homework 9

 
🔗
Simy1130 2016-4-5 22:13:11 | 只看该作者
全局:
hypsm 发表于 2016-2-4 02:18
搞完了,犯了一个超级超级傻逼的错误!
写出了这样一个判断:
   if(set.find(s1) != set.find(s2)) ...

我在if里用到递归了,可以成功运行啊
回复

使用道具 举报

🔗
Simy1130 2016-4-5 22:14:07 | 只看该作者
全局:
不难
还是按照老师的一步步走
个人觉得最难在于如何简洁表示wallArray数组。。。。= =

homewok9.JPG (88.82 KB, 下载次数: 0)

homewok9.JPG
回复

使用道具 举报

🔗
Damonizing 2016-4-11 18:02:31 | 只看该作者
全局:
本帖最后由 Damonizing 于 2016-4-11 23:28 编辑

看了好几遍才看懂题目。。。实现起来确实很简单。。。



评分

参与人数 1学分 +1 收起 理由
yingy4 + 1 坚持的不错,再接再厉!

查看全部评分

回复

使用道具 举报

🔗
shenrf 2016-4-14 20:58:26 | 只看该作者
全局:
还有最后一次作业了,比上劼慢了整整两个多月。。。这进度真是醉了。。。 来领学分,版主好久没有发学分了

HW9.png (37.84 KB, 下载次数: 0)

HW9.png

评分

参与人数 1学分 +1 收起 理由
yingy4 + 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.


评分

参与人数 1学分 +1 收起 理由
yingy4 + 1 坚持的不错,再接再厉!

查看全部评分

回复

使用道具 举报

🔗
Chris1993 2016-5-3 20:52:01 | 只看该作者
全局:
看懂题目花了很多时间。。最后根据一个墙的序号判断周围2个cell的时候一开始写错了,没注意vertical的顺序是按column排序的

Screen Shot 2016-05-03 at 8.33.37 PM.png (106.83 KB, 下载次数: 0)

Screen Shot 2016-05-03 at 8.33.37 PM.png

评分

参与人数 1学分 +1 收起 理由
yingy4 + 1 坚持的不错,再接再厉!

查看全部评分

回复

使用道具 举报

🔗
pirateshadow 2016-5-3 21:24:11 | 只看该作者
全局:
代码里面vertical和horizon混淆得厉害,写了5段调试代码才调好。。

Screen Shot 2016-05-03 at 9.00.59 PM.png (69.93 KB, 下载次数: 0)

Screen Shot 2016-05-03 at 9.00.59 PM.png

评分

参与人数 1学分 +1 收起 理由
yingy4 + 1 坚持的不错,再接再厉!

查看全部评分

回复

使用道具 举报

🔗
LockOn 2016-5-3 21:58:11 | 只看该作者
全局:
倒数第二个啦,对union find的实现有了进一步认识,用array实现确实非常方便。
要注意的是如何根据wallArray的序号倒推cell的序号。这里horizontal wall的横向range有h,vertical wall的横向range为h-1,在取模的时候需要注意。

hw9.PNG (29.33 KB, 下载次数: 0)

hw9.PNG

评分

参与人数 1学分 +1 收起 理由
yingy4 + 1 坚持的不错,再接再厉!

查看全部评分

回复

使用道具 举报

🔗
213123418 2016-5-5 20:24:27 | 只看该作者
全局:
debug了一晚上,结果就是做个乘法时写错位了。。。。

评分

参与人数 1学分 +1 收起 理由
yingy4 + 1 坚持的不错,再接再厉!

查看全部评分

回复

使用道具 举报

🔗
caominki 2016-5-8 09:40:57 | 只看该作者
全局:
还差一次作业了,不过学完后还是要系统的看一下。

Homework9.PNG (14.94 KB, 下载次数: 0)

Homework9.PNG

评分

参与人数 1学分 +1 收起 理由
yingy4 + 1 坚持的不错,再接再厉!

查看全部评分

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表