Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> การเขียนโปรแกรม

Weight-Biased Leftist Trees (WBLT) ในโครงสร้างข้อมูล


นิยาม WBLT

Leftist Tree แบบนี้พิจารณาจำนวนโหนดใน Subtree แทนที่จะเป็นความยาว Shortest Path จาก Root สู่ External Node นิยาม Weight w(x) ของโหนด x = จำนวน Internal Nodes ใน Subtree ที่ Root = x ถ้า x เป็น External Node w(x) = 0 ถ้าเป็น Internal Node w(x) = 1 + ผลรวม w ของลูกๆ

ตัวอย่าง

Binary Tree:

Weight-Biased Leftist Trees (WBLT) ในโครงสร้างข้อมูล

ค่า w(x) ทุกโหนด:

Weight-Biased Leftist Trees (WBLT) ในโครงสร้างข้อมูล

เงื่อนไข WBLT

Binary Tree เรียกว่า Weight Balanced Leftist Tree ก็ต่อเมื่อ: ที่ทุก Internal Node w(x) ของ Left Child ≥ w(x) ของ Right Child Max (Min) WBLT คือ Max (Min) Tree ที่เป็น WBLT ด้วย