查看: 3459| 回复: 19
跳转到指定楼层
上一主题 下一主题
收起左侧

Algorithms: Design and Analysis, Part 2, week2 交作业以及请教

全局:
公开课
学校名称: Stanford
Unit号: 2
开课时间: 2014-06-30
课程全名: Algorithms: Design and Analysis, Part 2
平台: Coursera

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看附件。没有帐号?注册账号

x
这次作业写了我好久。。。
第二道编程还是错的。。。怎么都找不出来错误。上来找高手答疑。。。

所有的test case我都过了。但是答案就是不对。。。我的答案是 6210.... 不知道大家有没有犯和我一样的错误,然后解决了的。。。快要抓狂了。
我的大概思路是参考了discussion forums上的:
每个node用十进制位数做key,然后用hash,我用了100个bucket,用余数来决定bucket。
然后类似第一题的思路,用union find。最后数有多少个leader node,就是答案。

死也没找到为啥出错。
求拍。。。。
更多图片 小图 大图
组图打开中,请稍候......

上一篇:[Coursera] Programming for Everybody (Week 7)
下一篇:[edX]Introduction to Computer Science and Programming Using Python@MITx week#4
推荐
kelvinzhong 2014-7-13 21:52:03 | 只看该作者
全局:
Problem Set #2 Help

Attempt Quiz
Due Date         Sun 20 Jul 2014 11:59 PM PDT
If you submit after the due date (but before the hard deadline), your submission score will be penalized 50%.

Hard Deadline         Sun 24 Aug 2014 11:59 PM PDT
If you submit any time after the hard deadline, you will not receive credit.

Effective Score        4.00 / 5.00
Explanation: 4.00 = 4.00 (Score for attempt 1) * 100% (No penalties)
Each time that you attempt it, we'll record a score based on your performance and any penalties due to late submissions. Your effective score will be the highest score of all the allowed attempts made before the hard deadline.

# of Attempts        2 / 2
Last Attempted        Mon 7 Jul 2014 7:35 AM PDT
Last Attempted Score        4.00 / 5.00Show Previous Attempts
  Programming Assignment #2
(collapsed, click to expand)
Completed
Programming Assignment #2 Help

Attempt Quiz
Due Date         Sun 20 Jul 2014 11:59 PM PDT
If you submit after the due date (but before the hard deadline), your submission score will be penalized 50%.

Hard Deadline         Sun 24 Aug 2014 11:59 PM PDT
If you submit any time after the hard deadline, you will not receive credit.

Effective Score        5.00 / 5.00
Explanation: 5.00 = 5.00 (Score for attempt 5) * 100% (No penalties)
Each time that you attempt it, we'll record a score based on your performance and any penalties due to late submissions. Your effective score will be the highest score of all the allowed attempts made before the hard deadline.

# of Attempts        5 / 15
Last Attempted        Tue 8 Jul 2014 8:24 AM PDT
Last Attempted Score        5.00 / 5.00Show Previous Attempts
回复

使用道具 举报

推荐
 楼主| xingzhui222 2014-7-14 00:09:26 | 只看该作者
全局:
kelvinzhong 发表于 2014-7-13 21:53
你的答案真的已经很接近了....但是思路是不是有点不对? 我第二题和第一题的思路完全不一样的..

能说说你第二题的思路么。

我的思路是参照论坛上的一个人的。
就是对每个node,我用combination找到1个不同的点,对应1的距离,2个不同的点,对应2的距离。然后用hashtable去找24*1+ 24*23/2 = 300个可能距离小于3的所有点是否在file里面,在的话,我就union find。

我对所有小数据上跑都没问题,我都怀疑是不是啥stack overflow类似的毛病了。。。
回复

使用道具 举报

推荐
 楼主| xingzhui222 2014-7-19 11:24:24 | 只看该作者
全局:
kelvinzhong 发表于 2014-7-17 23:55
同学week3做了吗?...求指导呀..不会做大数据的那个TAT...

做了2M个points那个,我是用了hash table,然后每次update的时候只保留一个column,这样可以不占用memory。。。

评分

参与人数 1大米 +10 收起 理由
kelvinzhong + 10 欢迎来一亩三分地论坛!

查看全部评分

回复

使用道具 举报

🔗
kelvinzhong 2014-7-13 21:51:36 | 只看该作者
全局:
这个我也用了很长时间...
回复

使用道具 举报

🔗
kelvinzhong 2014-7-13 21:53:56 | 只看该作者
全局:
你的答案真的已经很接近了....但是思路是不是有点不对? 我第二题和第一题的思路完全不一样的..
回复

使用道具 举报

🔗
kelvinzhong 2014-7-14 09:26:43 | 只看该作者
全局:
xingzhui222 发表于 2014-7-14 00:09
能说说你第二题的思路么。

我的思路是参照论坛上的一个人的。

我也是这么做的.........
回复

使用道具 举报

🔗
 楼主| xingzhui222 2014-7-14 11:44:37 | 只看该作者
全局:
kelvinzhong 发表于 2014-7-14 09:26
我也是这么做的.........

额,那就更奇怪了。。。理论上如果我出错了的话,test cases应该通不过才对。。。真是懊恼啊。。
你是用啥写的? running time是多少呀?
回复

使用道具 举报

🔗
kelvinzhong 2014-7-14 19:39:04 | 只看该作者
全局:
这。。我当时没有跑test cases..python, runningtime应该和你一样, 200000*300
回复

使用道具 举报

🔗
 楼主| xingzhui222 2014-7-15 06:18:11 | 只看该作者
全局:
kelvinzhong 发表于 2014-7-14 19:39
这。。我当时没有跑test cases..python, runningtime应该和你一样, 200000*300

Thanks for your help!!!
I found a tiny bug in my code and it is fixed now.
回复

使用道具 举报

🔗
breezet 2014-7-17 23:23:30 | 只看该作者
全局:
回复

使用道具 举报

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

本版积分规则

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