【数据结构与算法】二叉搜索树V2.0的Java实现
生活随笔
收集整理的這篇文章主要介紹了
【数据结构与算法】二叉搜索树V2.0的Java实现
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
更新說明
在二叉搜索樹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總結
以上是生活随笔為你收集整理的【数据结构与算法】二叉搜索树V2.0的Java实现的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【计算机网络】计算机网络概述
- 下一篇: java美元兑换,(Java实现) 美元