iT邦幫忙

0

關於B tree的建立

題目為: 開始插入的資料順序為:29、31、2、71、5、17、26、 53 與 23,試建立所對應的 B_tree。

我這邊學到主要的三個概念為:

  1. 每個node最多放兩個數字
  2. 數字大的往右找和放右邊(反之)
  3. 當node裡面有三個數字時,把中間的數字往上題,然後原本的兩個數字分割

第一步: 一個29
https://ithelp.ithome.com.tw/upload/images/20211021/20119434PrTCMkYkKg.png

第二步: 31比29大,放右邊
https://ithelp.ithome.com.tw/upload/images/20211021/20119434k4G2200GBa.png

第三步: 放入2後,變成三個數,把中間的29往上提
https://ithelp.ithome.com.tw/upload/images/20211021/20119434zHnk6bw85D.png

第四步: 71比29大,往右邊找,比31大放右邊
https://ithelp.ithome.com.tw/upload/images/20211021/20119434snDaxEZcCI.png

第五步: 5比29小,往左找,比2大放右邊
https://ithelp.ithome.com.tw/upload/images/20211021/20119434rBdHzAiNbg.png

第六步: 17比29小,往左找,2、5、17有三個數,把中間的5往上提,2和17被分割
https://ithelp.ithome.com.tw/upload/images/20211021/201194343HYYicG6eQ.png

第七步: 26放進來(介於5和29中間),有三個數,把中間的26往上提,5和29被分割,但是分割後原本底下那些2、17、(31和71)是在放在5的底下還是29的底下? 還是?
https://ithelp.ithome.com.tw/upload/images/20211021/20119434Gk4psLraTy.png

做到這裡就卡住了,請問接下來該怎麼做呢??

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

2
海綿寶寶
iT邦大神 1 級 ‧ 2021-10-21 09:11:17
最佳解答
聰明貓 iT邦新手 4 級 ‧ 2021-10-21 19:01:30 檢舉

謝謝大神~

我要發表回答

立即登入回答