5th Apr, 2016

Data Structure – Pertemuan 5 (Rangkuman)

Data Structure (Conclusion)

Binary Search TreeBinary 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)

  1. Move to 8 (13 > 8, move to right)
  2. Move to 10 (13 > 10, move to right)
  3. Move to 14 (13 < 14, move to left)
  4. Move to 13 (13 = 13, End)

Insert Algorithm (Insert : 5)

  1. Move to 8 (5 < 8, move to left)
  2. Move to 3 (5 > 3, move to right)
  3. Move to 6 (5 < 6, move to left)
  4. Move to 4 (5 > 4, move to right)
  5. Empty node (Make new node, Insert 5)

Delete Algorithm (Delete : 3)

  1. Move to 8 (3 < 8, move to left)
  2. Move to 3 (3 = 3)
  3. Search the highest node’s value
  4. Move to 6 (node 6 still have higher node [Left Child])
  5. Move to 7 (node 7 don’t have Left Child)
  6. Move node 7  to the node 3 (Replace 3)
  7. Free node 3

Leave a response

Your response:

Categories