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

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

全局:
公开课
学校名称: Berkeley
Unit号: 11
开课时间: 2014
课程全名: Berkeley CS 61B Data Structures(in Java)
平台: 其他

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

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

x
没找到lab11的帖子 就自己发一个了

lab11  感觉有一个地方要考虑 就是remove1的时候  一开始把2当做root。。。发现应该让6作为root
有点懵  感觉是不是当root的左右有一边没有node时 是不是就应该把root放到有节点的一边 直接删除原root 从而使tree尽量平衡
刚学 不懂  求大神讲解。

上一篇:有没有上过udacity self-driving car?
下一篇:求抱团监督取暖~
推荐
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
复制代码
回复

使用道具 举报

推荐
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 给你点个赞!

查看全部评分

回复

使用道具 举报

推荐
arcolin 2017-5-12 21:26:23 | 只看该作者
全局:
重新做人
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
回复

使用道具 举报

红色山峰 该用户已被删除
🔗
红色山峰 2017-1-13 20:44:51 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

🔗
 楼主| cxw111 2017-1-14 21:18:33 | 只看该作者
全局:
红色山峰 发表于 2017-1-13 20:44
还没看到这,问下这个课的作业和project是用什么IDE的?

我用的eclipse。。
回复

使用道具 举报

🔗
wzhbtbt 2017-1-16 16:30:35 | 只看该作者
全局:
帮顶下,LZ学得真快
回复

使用道具 举报

🔗
mmyn 2017-5-14 17:17:56 | 只看该作者
全局:
做了homework7的234tree感觉binaryTree随手就能写真是平易近人 ><
回复

使用道具 举报

🔗
SaltSprayAir 2017-7-5 17:38:15 | 只看该作者
全局:
做完hw7这个就真的轻松

Screen Shot 2017-07-05 at 02.36.33.png (86.21 KB, 下载次数: 0)

Screen Shot 2017-07-05 at 02.36.33.png
回复

使用道具 举报

🔗
yywwd 2017-8-3 10:28:09 | 只看该作者
全局:
打卡!讲义上有写 If n has one child, move n's child up to take n's place. 1是root时,只有一个child
回复

使用道具 举报

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

本版积分规则

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