您当前的位置: 首页 >  搜索

星拱北辰

暂无认证

  • 0浏览

    0关注

    1205博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

【数据结构与算法】二叉搜索树V2.0的Java实现

星拱北辰 发布时间:2020-02-23 11:02:47 ,浏览量:0

更新说明

在二叉搜索树V1.0的编程实现中,我们实现了BST的查找、插入,左右儿子删除的功能,但写的确实很一般,这里就Update一下。

功能介绍
  • void insert(x) → Insert x
  • void remove(x) → Remove x
  • boolean contains(x) → Return true if x is present
  • Comparable findMin() → Return smallest item
  • Comparable findMax() → Return largest item
  • boolean isEmpty() → Return true if empty; else false
  • void makeEmpty() → Remove all items
  • void printTree() → Print tree in sorted order
异常类

当集合容器为空的时候就不能够删除或获取元素,这时就会出现一种异常,命名为UnderflowException:

/**
 * Exception class for access in empty containers
 * such as stacks, queues, and priority queues.
 */
public 
关注
打赏
1660750074
查看更多评论
立即登录/注册

微信扫码登录

0.0625s