一亩三分地论坛

 找回密码
 获取更多干货,去instant注册!

扫码关注一亩三分地公众号
查看: 1023|回复: 13
收起左侧

2016 9月 Algorithm,Part1 week3 作业帖

[复制链接] |试试Instant~ |关注本帖
minchen57 发表于 2016-9-7 10:08:17 | 显示全部楼层 |阅读模式

[Coursera]Algorithm,Part1 #3 - 2016-09-02@Princeton University

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

您需要 登录 才可以下载或查看,没有帐号?获取更多干货,去instant注册!

x
课程汇总 && 介绍:http://www.1point3acres.com/bbs/thread-200970-1-1.html

第三次作业,Collinear Points, 作业入口

zzdsg 发表于 2016-9-10 21:38:52 | 显示全部楼层
先后提交了九遍,看了网上的提示才得了满分。。。心累
无标题.png
回复 支持 反对

使用道具 举报

youngyang 发表于 2016-9-22 22:12:00 | 显示全部楼层
适当的使用Arrays.sort()非常有用!
捕获.PNG
回复 支持 反对

使用道具 举报

 楼主| minchen57 发表于 2016-9-24 05:45:07 | 显示全部楼层
交作业,

week3

week3



还是废了点时间的
回复 支持 反对

使用道具 举报

loveyomin 发表于 2016-9-25 21:01:46 | 显示全部楼层
请问,这个问题是啥问题?我程序里调用了point.toString()方法。。。
Test 8: Check for fragile dependence on return value of toString()
  *  filename = equidistant.txt
     -  student   solution has 1 non-null entries
     -  reference solution has 4 non-null entries
     -  3 missing entries in student solution, including: (30000, 0) -> (20000, 10000) -> (10000, 20000) -> (0, 30000)

  *  filename = input40.txt
     -  student   solution has 1 non-null entries
     -  reference solution has 4 non-null entries
     -  3 missing entries in student solution, including: (2000, 29000) -> (4000, 29000) -> (22000, 29000) -> (28000, 29000)

  *  filename = input48.txt
     -  student   solution has 1 non-null entries
     -  reference solution has 6 non-null entries
     -  5 missing entries in student solution, including: (1000, 26000) -> (9000, 26000) -> (11000, 26000) -> (18000, 26000)

==> FAILED
回复 支持 反对

使用道具 举报

Raymomd 发表于 2016-9-26 02:00:20 | 显示全部楼层
loveyomin 发表于 2016-9-25 21:01
请问,这个问题是啥问题?我程序里调用了point.toString()方法。。。
Test 8: Check for fragile dependen ...

就是没有找全所有的共线点
回复 支持 反对

使用道具 举报

Raymomd 发表于 2016-9-26 02:47:28 | 显示全部楼层
提交作业,没有满分的原因是改变了传入单数points,但是要用Arrays.sort 就会改变原点阵,除非重新建矩阵,但是这样多用了spacet Screen Shot 2016-09-25 at 13.45.23.png
回复 支持 反对

使用道具 举报

loveyomin 发表于 2016-9-26 19:51:48 | 显示全部楼层
Raymomd 发表于 2016-9-26 02:47
提交作业,没有满分的原因是改变了传入单数points,但是要用Arrays.sort 就会改变原点阵,除非重新建矩阵, ...

effective java 里面建议 不要改变传入的参数,所以测试里才会有测试参数。。。points.clone()新建矩阵就好。空间满足题设要求,memory测试也是可以过的。。
回复 支持 反对

使用道具 举报

loveyomin 发表于 2016-9-26 19:53:12 | 显示全部楼层
Raymomd 发表于 2016-9-26 02:00
就是没有找全所有的共线点

嗯,错误提示是这个,但关键是,,,本机跑出来的结果是对的,比如第一个,他说student solution 1 non-null entries,但实际上我debug的结果就是4个。。。
回复 支持 反对

使用道具 举报

Raymomd 发表于 2016-9-26 21:55:24 | 显示全部楼层
loveyomin 发表于 2016-9-26 19:53
嗯,错误提示是这个,但关键是,,,本机跑出来的结果是对的,比如第一个,他说student solution 1 non-n ...

咦,你有testcode吗,哪里可以找到啊,我一开始和你有一样的问题,但后来发现还是没考虑所有情况
回复 支持 反对

使用道具 举报

Raymomd 发表于 2016-9-26 21:57:08 | 显示全部楼层
loveyomin 发表于 2016-9-26 19:51
effective java 里面建议 不要改变传入的参数,所以测试里才会有测试参数。。。points.clone()新建矩阵就 ...

嗯,知道怎么改了,但是太懒了
回复 支持 反对

使用道具 举报

farewell 发表于 2016-9-28 13:15:22 | 显示全部楼层
做的好心烦,先这样交作业求学分
Collinear.png
回复 支持 反对

使用道具 举报

nsc 发表于 2016-10-24 10:31:12 | 显示全部楼层
还有些bug没解决。先提交下作业吧
Untitled.png
回复 支持 反对

使用道具 举报

nsc 发表于 2016-11-17 17:12:09 | 显示全部楼层
程序里还有两个错误一直没解决。满分的同学能否给点提示?谢谢!

BruteCollinearPoints.java和FastCollinearPoints.java里各一个错误,类型相同。

Test 10: Check that data type is immutable by testing whether each method
        returns the same value, regardless of any intervening operations
  *  input8.txt
     -  failed after 12 operations involving BruteCollinearPoints
     -  first and last call to segments() returned different arrays
     -  sequence of operations was:
          BruteCollinearPoints collinear = new BruteCollinearPoints(points);
          collinear.numberOfSegments() -> 2
          collinear.numberOfSegments() -> 2
          mutate points[] array that was passed to constructor
          mutate points[] array that was passed to constructor
          collinear.numberOfSegments() -> 2
          mutate points[] array that was passed to constructor
          collinear.segments()
          mutate array returned by last call to segments()
          collinear.numberOfSegments() -> 2
          collinear.numberOfSegments() -> 2
          collinear.segments()
     -  failed on trial 1 of 100

  *  equidistant.txt
     -  failed after 9 operations involving BruteCollinearPoints
     -  first and last call to segments() returned different arrays
     -  sequence of operations was:
          BruteCollinearPoints collinear = new BruteCollinearPoints(points);
          mutate points[] array that was passed to constructor
          collinear.segments()
          collinear.numberOfSegments() -> 4
          mutate points[] array that was passed to constructor
          mutate array returned by last call to segments()
          collinear.numberOfSegments() -> 4
          mutate points[] array that was passed to constructor
          collinear.segments()
     -  failed on trial 1 of 100

==> FAILED

Test 13: Check that data type is immutable by testing whether each method
         returns the same value, regardless of any intervening operations
  *  input8.txt
     -  failed after 10 operations involving FastCollinearPoints
     -  first and last call to segments() returned different arrays
     -  sequence of operations was:
          FastCollinearPoints collinear = new FastCollinearPoints(points);
          collinear.numberOfSegments() -> 2
          collinear.segments()
          mutate points[] array that was passed to constructor
          collinear.segments()
          mutate array returned by last call to segments()
          mutate points[] array that was passed to constructor
          mutate points[] array that was passed to constructor
          collinear.numberOfSegments() -> 2
          collinear.segments()
     -  failed on trial 1 of 100

  *  equidistant.txt
     -  failed after 11 operations involving FastCollinearPoints
     -  first and last call to segments() returned different arrays
     -  sequence of operations was:
          FastCollinearPoints collinear = new FastCollinearPoints(points);
          collinear.numberOfSegments() -> 4
          collinear.numberOfSegments() -> 4
          collinear.segments()
          mutate points[] array that was passed to constructor
          collinear.segments()
          collinear.numberOfSegments() -> 4
          collinear.numberOfSegments() -> 4
          collinear.numberOfSegments() -> 4
          mutate array returned by last call to segments()
          collinear.segments()
     -  failed on trial 1 of 100

==> FAILED

回复 支持 反对

使用道具 举报

本版积分规则

请点这里访问我们的新网站:一亩三分地Instant.

Instant搜索更强大,不扣积分,内容组织的更好更整洁!目前仍在beta版本,努力完善中!反馈请点这里

关闭

一亩三分地推荐上一条 /5 下一条

手机版|小黑屋|一亩三分地论坛声明 ( 沪ICP备11015994号 )

custom counter

GMT+8, 2016-12-8 16:04

Powered by Discuz! X3

© 2001-2013 Comsenz Inc. Design By HUXTeam

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