📣 黑五价提前开抢|VIP一年通行证5折,蓝莓、Offer多多同步特惠
楼主: jaly50
跳转到指定楼层
上一主题 下一主题
收起左侧

Berkeley CS 61B Data Structures(in Java) Homework4 加分+讨论帖

 
🔗
shuaishuaima 2015-9-8 05:55:29 | 只看该作者
全局:
本帖最后由 shuaishuaima 于 2015-9-8 06:10 编辑

交作业了,费了好大劲....上传图片错了,只能明天再交了


回复

使用道具 举报

🔗
merSalesLa 2015-10-8 21:17:41 | 只看该作者
全局:
先是TestDList的输出结果:
  1. Now we are testing DList.
  2. Here is a list after insertBack 6, 9, 12: [  6  9  12  ]

  3. Here is the same list after insertBack(15) and insertFront(3): [  3  6  9  12  15  ]

  4. front() should be 3. It is: 3
  5. front's next should be 6. It is: 6
  6. front's next's prev should be 3. It is: 3
  7. After remove the front, the front() should be 6. It is: 6
  8. After insertBefore() and insertAfter(), The first 3 nodes should be 5,6,8. The list is: [  5  6  8  9  12  15  ]

  9. Here is a list after construction: [  ]
  10. isEmpty() should be true. It is: true
  11. length() should be 0. It is: 0
  12. Here is a list after insertFront(3) to an empty list: [  3  ]
  13. Here is a list after insertBack(5) on an empty list: [  5  ]

  14. Here is a list after insertFront 3, 2, 1: [  1  2  3  ]
  15. isEmpty() should be false. It is: false
  16. length() should be 3. It is: 3
  17. Here is the same list after insertBack(4): [  1  2  3  4  ]

  18. Here is a list after insertBack 6, 7: [  6  7  ]
  19. isEmpty() should be false. It is: false
  20. length() should be 2. It is: 2
  21. Here is the same list after insertFront(5): [  5  6  7  ]
复制代码
再是TestLockDlist的输出结果:
  1. Now we are testing LockDList.
  2. Here is a list after insertBack 6, 9, 12: [  6  9  12  ]

  3. Here is the same list after insertBack(15) and insertFront(3): [  3  6  9  12  15  ]

  4. front() should be 3. It is: 3
  5. front's next should be 6. It is: 6
  6. front's next's prev should be 3. It is: 3
  7. We lockNode front()= 3
  8. After remove the locked front, the front() should still be 3. It is: 3
  9. After remove the back, the back() should be 12. It is: 12
  10. After insertBefore(3) and insertAfter(3), The first 3 nodes should be 5,3,8. The list is: [  5  3  8  6  9  12  ]

  11. Here is a list after construction: [  ]
  12. isEmpty() should be true. It is: true
  13. length() should be 0. It is: 0
  14. Here is a list after insertFront(3) to an empty list: [  3  ]
  15. Here is a list after insertBack(5) on an empty list: [  5  ]

  16. Here is a list after insertFront 3, 2, 1: [  1  2  3  ]
  17. isEmpty() should be false. It is: false
  18. length() should be 3. It is: 3
  19. Here is the same list after insertBack(4): [  1  2  3  4  ]

  20. Here is a list after insertBack 6, 7: [  6  7  ]
  21. isEmpty() should be false. It is: false
  22. length() should be 2. It is: 2
  23. Here is the same list after insertFront(5): [  5  6  7  ]
复制代码
PS.问题求解答~
做第一部分的时候,一直出现空DList的插入报错,后来把DList Constructor中的
head= newNode(null,head,head);
改成
  head= newNode(null,null,null);
  head.prev= head.next = head;
就没问题了,不理解为什么>_<
回复

使用道具 举报

🔗
iamash 2015-10-11 08:29:53 | 只看该作者
全局:
第四次作业啦!这次作业还比较简单,楼主别忘给我加学分额。。之前的都没加



回复

使用道具 举报

全局:
一开始test一直过不了 心好累 lz的test sl1.front()和back显示cannot convert
后来发现是 因为我没有override这两个method 于是return类型不是LockDList
看到要求里面有写尽可能少override 就不改了
用了Github的测试数据 求加分 谢谢版大~
更多图片 小图 大图
组图打开中,请稍候......
回复

使用道具 举报

全局:
花了小半天,done
更多图片 小图 大图
组图打开中,请稍候......
回复

使用道具 举报

🔗
ohmyonetwo 2015-11-4 12:51:48 | 只看该作者
全局:
homework 4有点难啊
更多图片 小图 大图
组图打开中,请稍候......
回复

使用道具 举报

🔗
jigsaw_Becky 2015-11-6 21:40:50 | 只看该作者
全局:
原来LZ分享了测试代码的!后知后觉!
更多图片 小图 大图
组图打开中,请稍候......
回复

使用道具 举报

🔗
ohmyonetwo 2015-11-7 15:38:12 | 只看该作者
全局:
gloria_wwj 发表于 2014-7-14 18:05
想到了调用父类,但是调代码的时候说必须super是第一个statement~所以就放弃了

课上讲,写constructor的时候必须首先super,其他的可以不用
回复

使用道具 举报

🔗
rushiwowen92 2015-11-14 04:39:45 | 只看该作者
全局:
虽然结果看着对了,但总觉得自己的继承的时候有点笨,好想看看别人怎么写的啊
更多图片 小图 大图
组图打开中,请稍候......
回复

使用道具 举报

🔗
lqwandyy 2015-11-20 00:45:59 | 只看该作者
全局:
homework4-part1

hw4-1.jpg (84.29 KB, 下载次数: 0)

hw4-1.jpg
回复

使用道具 举报

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

本版积分规则

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