1. 程式人生 > >Woolsey渣渣要好好學習

Woolsey渣渣要好好學習

B+樹是一種n叉樹,它將所有資料存在一個level中。B+ 樹的特點是能夠保持資料穩定有序,其插入與修改擁有較穩定的對數時間複雜度。因此B+樹被應用於資料庫和作業系統的檔案系統中。
B+樹的理解沒有紅黑樹這麼複雜,本文將首先簡要介紹B+樹,然後分析B+樹的先關題目。本文重點是最後一部分。

介紹

A B+ tree of order M is a tree with the following structural properties:
(1) The root is either a leaf or has between 2 and M children.
(2) All nonleaf nodes (except the root) have between

M/2 and M children.
(3) All leaves are at the same depth.
Assume each nonroot leaf also has between M/2 and M children.

需要注意:

  1. 每個儲存資料的葉節點,其中的資料數量在M/2 與 M之間(閉區間)。若超出這個區間,則進行調整。
  2. 從空樹開始時,資料首先存放在根節點中,當根節點的資料大於M時再進行調整。
  3. 根的子節點數最小為2, 而其他非根節點的子節點數最小為 M/2

相關題目

Insert 3, 1, 4, 5, 9, 2, 6, 8, 7, 0 into an initially empty 2-3 tree (with splitting). Which one of the following statements is FALSE? (2分)
A. 7 and 8 are in the same node
B. the parent of the node containing 5 has 3 children
C. the first key stored in the root is 6
D. there are 5 leaf nodes

解題過程

故選A

After deleting 9 from the 2-3 tree given in the figure, which one of the following statements is FALSE? (2分)
題目配圖
A. the root is full
B. the second key stored in the root is 6
C. 6 and 8 are in the same node
D. 6 and 5 are in the same node

這裡寫圖片描述

故選D

Which of the following statements concerning a B+ tree of order M is TRUE? (2分)
A. the root always has between 2 and M children
B. not all leaves are at the same depth
C. leaves and nonleaf nodes have some key values in common
D. all nonleaf nodes have between ⌈M/2⌉ and M children

A. 當只有root一個節點時,root沒有孩子。故錯。
B. 這違反了定義“所有葉節點位於同一深度”。
C. 正確。
D. 除了根節點外的非葉結點有 ⌈M/2⌉ 與 M 之間的子節點。
故選D