看板 Grad-ProbAsk 關於我們 聯絡資訊
畫出產生的AVL樹,每棵樹各自獨立,對原先的樹加入/刪除資料 40 20 80 10 30 60 90 25 35 50 70 10、90沒有子樹 問題如下: (1)加入資料26 (2)加入資料46 (3)刪除資料30 我劃出結果(1) 40 20 80 10 30 60 90 25 35 50 70 26 (2) 40 20 80 10 30 60 90 25 35 50 70 26 46 (3) 40 20 80 10 26 60 90 25 35 50 70 46 樹枝畫不出來,希望不會造成看文章的困惱,我盡量湊成對了,希望不會傷眼!! 請益一下,二元搜尋找到最大值,可以使用以下範例去證明之嗎。說明根的特性。 int left_child(int index) {return index * 2;} int right_child(int index) {return index * 2 + 1;} void binary_tree() { int tree[5 + 1]; cout << "根為" << tree[1]; cout << "根的左邊小孩是" << tree[left_child(1)]; cout << "根的右邊小孩是" << tree[right_child(1)]; } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.39.8.164
kyodaisuki:圖一 20的左右子樹不平衡 要改 圖二 80同理 03/20 02:31
kyodaisuki:是一步改一次 不是一次做完 03/20 02:31
A4P8T6X9:下面那個要 complete 才有這樣的性質。 03/20 07:54
hsuanyao:每做一步就要檢查一次唷 03/22 00:06