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

Berkeley CS 61B Data Structures(in Java) Lab11讨论帖

🔗
yagamy 2017-8-10 07:54:06 | 只看该作者
全局:
这个binaryTree看似简单,其实implement起来还挺复杂的,特别是remove的情况要考虑清楚,如果remove的是root,有可能还会发生nullPointer的情况,还要考虑root的左右child各自是不是null,debug了蛮久。不过比起hw7的234Tree已经要好多啦!

lab11.PNG (33.36 KB, 下载次数: 1)

lab11.PNG
回复

使用道具 举报

全局:

打卡lab11
虽然没有hw7那么麻烦 但是和wh7一样都做了3个小时- -
回复

使用道具 举报

🔗
elemist 2017-11-30 05:34:30 | 只看该作者
全局:
Lab 11 打卡啦,继续努力,这么课终于要结束了。
Inserting 1A, 6V, 3K, 2Z, 5L, 9L:
The tree is:  1A(((2Z)3K(5L))6V(9L))
Size:  6

Testing find() ...
Calling find() on 1
  returned A.
Calling find() on 9
  returned L.
Calling find() on 5
  returned L.
Calling find() on 4
  returned null.
Calling find() on 6
  returned V.
Calling find() on 3
  returned K.

Testing remove() (for nodes with < 2 children) ...
After remove(5):  1A(((2Z)3K)6V(9L))
After remove(3):  1A((2Z)6V(9L))
After remove(1):  (2Z)6V(9L)
After inserting 7S, 8X, 10B:  (2Z)6V((7S(8X))9L(10B))
Size:  6

Testing remove() (for nodes with 2 children) ...
After remove(6):  (2Z)7S((8X)9L(10B))
After remove(9):  (2Z)7S((8X)10B)
Size:  4
>

评分

参与人数 1大米 +1 收起 理由
DreamfulSage + 1 给你点个赞!

查看全部评分

回复

使用道具 举报

🔗
skyevil12 2017-12-11 10:13:01 | 只看该作者
全局:
Binary tree find and remove impl.

  1. D:\Git\DSA\CS61B\lab11>java -ea dict.BinaryTree
  2. Inserting 1A, 6V, 3K, 2Z, 5L, 9L:
  3. The tree is:  1A(((2Z)3K(5L))6V(9L))
  4. Size:  6

  5. Testing find() ...
  6. Calling find() on 1
  7.   returned A.
  8. Calling find() on 9
  9.   returned L.
  10. Calling find() on 5
  11.   returned L.
  12. Calling find() on 4
  13.   returned null.
  14. Calling find() on 6
  15.   returned V.
  16. Calling find() on 3
  17.   returned K.

  18. Testing remove() (for nodes with < 2 children) ...
  19. After remove(5):  1A(((2Z)3K)6V(9L))
  20. After remove(3):  1A((2Z)6V(9L))
  21. After remove(1):  (2Z)6V(9L)
  22. After inserting 7S, 8X, 10B:  (2Z)6V((7S(8X))9L(10B))
  23. Size:  6

  24. Testing remove() (for nodes with 2 children) ...
  25. After remove(6):  (2Z)7S((8X)9L(10B))
  26. After remove(9):  (2Z)7S((8X)10B)
  27. Size:  4
复制代码
回复

使用道具 举报

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

本版积分规则

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