遞歸反轉
![](http://static.javashuo.com/static/loading.gif)
二分查找
![](http://static.javashuo.com/static/loading.gif)
AVL樹
![](http://static.javashuo.com/static/loading.gif)
- AVL簡單的理解,如圖所示,底部節點爲1,不斷往上到根節點,數字不斷累加。
- 觀察每一個節點數字,隨意選個節點A,會發現A節點的左子樹節點或右子樹節點末尾,數到A節點距離之差不會超過1
- 一旦添加一個數,使得二叉樹結構,存在節點兩邊子樹差大於1,如果右子樹大,則左旋;左子樹大,則右旋。
- 旋轉規則關鍵節點就是這個A節點,右子樹大,則A節點變爲左子樹,右子節點替代A節點位置並指向A
紅黑樹
- 節點是紅色或黑色。
- 根節點是黑色。
- 每一個葉子節點都是黑色的空節點(NIL節點)。
- 每一個紅色節點的兩個子節點都是黑色。(從每一個葉子到根的全部路徑上不能有兩個連續的紅色節點)
- 從任一節點到其每一個葉子的全部路徑都包含相同數目的黑色節點。
![](http://static.javashuo.com/static/loading.gif)
參考 https://www.sohu.com/a/201923614_466939設計
伸展樹 - Splay
![](http://static.javashuo.com/static/loading.gif)
- 在伸展樹上的通常操做都基於伸展操做:假設想要對一個二叉查找樹執行一系列的查找操做,爲了使整個查找時間更小,被查頻率高的那些條目就應當常常處於靠近樹根的位置。因而想到設計一個簡單方法, 在每次查找以後對樹進行調整,把被查找的條目搬移到離樹根近一些的地方。伸展樹應運而生。伸展樹是一種自調整形式的二叉查找樹,它會沿着從某個節點到樹根之間的路徑,經過一系列的旋轉把這個節點搬移到樹根去。
- 插入,查找,刪除都會通過搬運到樹根的過程
哈希表插入 - hash
![](http://static.javashuo.com/static/loading.gif)
字典樹Trie
![](http://static.javashuo.com/static/loading.gif)
基數樹 - Radix Tree
![](http://static.javashuo.com/static/loading.gif)
三元搜索樹 - Ternary Search Tree
![](http://static.javashuo.com/static/loading.gif)
B樹
- B樹的平衡性很好,一個節點的最大數量取決於階數
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
B+樹
- B+樹相比B樹查詢效率更高
- b+樹的中間節點不保存數據,因此磁盤頁能容納更多節點元素,更「矮胖」;
- b+樹查詢必須查找到葉子節點,b樹只要匹配到便可不用管元素位置,所以b+樹查找更穩定(並不慢);
- 對於範圍查找來講,b+樹只需遍歷葉子節點鏈表便可,b樹卻須要重複地中序遍歷
![](http://static.javashuo.com/static/loading.gif)