Data Structure (Conclusion)
Binary Search Tree –> Mudah dilihat dan dipahami karena terurut. Anak kiri lebih kecil daripada anak kanan.
Operasi BST
– Search / Find(x)
– Insertion / Insert(x)
– Deletionn / remove(x)
Search Algorithm (Find : 13)
- Move to 8 (13 > 8, move to right)
- Move to 10 (13 > 10, move to right)
- Move to 14 (13 < 14, move to left)
- Move to 13 (13 = 13, End)
Insert Algorithm (Insert : 5)
- Move to 8 (5 < 8, move to left)
- Move to 3 (5 > 3, move to right)
- Move to 6 (5 < 6, move to left)
- Move to 4 (5 > 4, move to right)
- Empty node (Make new node, Insert 5)
Delete Algorithm (Delete : 3)
- Move to 8 (3 < 8, move to left)
- Move to 3 (3 = 3)
- Search the highest node’s value
- Move to 6 (node 6 still have higher node [Left Child])
- Move to 7 (node 7 don’t have Left Child)
- Move node 7 to the node 3 (Replace 3)
- Free node 3
Posted by: dennisht
Categories:
Uncategorized