1 / 22

TREES

TREES. Tree. Minimal Terdiri dari 1 node (simpul). node. root. m – ary Tree. leaf. leaf. Branch. binary. Binary Tree. Binary juga disebut 2-ary Tree Yaitu Tree dengan anak <=2. +. A. B. Representasi Infix pada Tree. 1. Infix A+B. 2. Infix A * B ^ C – D. -. D. *. A. ^. B.

gail-huber
Download Presentation

TREES

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. TREES

  2. Tree • Minimal Terdiri dari 1 node (simpul) node root m – ary Tree leaf leaf Branch

  3. binary Binary Tree Binary juga disebut 2-ary Tree Yaitu Tree dengan anak <=2

  4. + A B Representasi Infix pada Tree 1. Infix A+B 2. Infix A * B ^ C – D - D * A ^ B C

  5. + / A D B E Representasi Infix pada Tree 3. Infix (A+B) * C + D / E + * C

  6. Tree Level • Tree dibawah N0 Level 0 N3 Level 1 N1 N2 Level 2 N5 N4 N6 N7 N8 N9 N10 N11 Level 3

  7. Tree Level • Keterangan Root = N0 Leaf = N4,N5,N6,N7,N9,N10,N11 Branch node = N1,N2,N3,N8 T1 = N1,N4,N5,N6 T2 = N2,N7 T3 = N3,N8,N9,N10,N11 Depth = Max Level

  8. N0 N3 N1 N9 N8 N4 N5 N6 N10 N11 N2 N7 Representasi Tree 1. Diagram Venn

  9. Representasi Tree 2. Pedigree Chart N0 N3 N1 N2 N5 N4 N6 N7 N8 N9 N10 N11

  10. N4 N5 N1 N6 N0 N2 N7 N10 N8 N3 N11 N9 Representasi Tree 3. Linear chart

  11. Representasi Tree 4. Nested Parentheses (N0(N1(N4)(N5)(N6))(N2(N7)) (N3(N8(N10)(N11))(N9)))

  12. N0 N1 N4 N5 N6 N2 N7 N3 N8 N10 N11 N9 Representasi Tree 5. Bar Chart

  13. Representasi Tree 6. Level-Number Chart 1 N0 2 N1 3 N4 3 N5 3 N6 2 N2 3 N7 2 N3 3 N8 4 N10 4 N11 3 N9

  14. A A ≠ B B A A = B B General Tree Vs Binary Tree • General Tree • Binary Tree

  15. A B C D E F G J K H I Binary Tree dalam Array • Representasi Binary Tree pada Array Anak kiri = 2n Anak Kanan = 2n+1 n = index saat ini

  16. Konversi General Tree ke Binary Tree • Langkah-langkah konversi: • menghapus semua cabang (branch) yang terhubung pada setiap node, kecuali cabang yang paling kiri. Selanjutnya menghubungkan semua node pada level yang sama dengan branch • mengubah menjadi binary-tree, di mana branch kiri adalah branch yang vertical & branch kanan adalah branch yang horizontal.

  17. B B A Y A Y Z C Z J P H C H I J X I P N O N X O Konversi General Tree ke Binary Tree

  18. B A C Y H Z I J N P O X Konversi General Tree ke Binary Tree

  19. Data L – Child R – Child L R D Print Data Traversal Pada Binary Tree • Traversal Inorder : L D R • Traversal Preorder : D L R • Traversal Postorder : L R D

  20. B A A B C C D E Traversal Pada Binary Tree • Inorder = A B C • Preorder = B A C • Postorder = A C B • Inorder = D B E A C • Preorder = A B D E C • Postorder = D E B C A

  21. A A A B B C D B C D E C E F G F D E F G G Traversal Pada Binary Tree Inorder : E FG B C D A Preorder : A B E F G C D Postorder : G F E D C B A

  22. Soal Gambarkan Binary Tree yang dimaksud • Traversal Preorder : ABCDEFGHI • Traversal Inorder : CDEBFAIHG • Traversal Postorder: EDACGFBH, jumlah child untuk masing-masing node adalah: A = 1; B = 2; C = 0; D = 1; E = 0; F = 1; G = 0; H = 2

More Related