1 / 24

BAB 5

BAB 5. TREE. (Pohon). 179. Peng-alokasi-an memory. struktur. Stack Queue Tree. Satu dimensi. Stack. linear. Array. (statis). Queue. Dua dimensi. Graph. Tree. Stack Queue. Linear. non linear. Linked- List. Graph. (dinamis). Non Linear. Tree Graph. A. B. C. D.

vernon
Télécharger la présentation

BAB 5

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. BAB 5 TREE (Pohon) 179

  2. Peng-alokasi-an memory struktur Stack Queue Tree Satu dimensi Stack linear Array (statis) Queue Dua dimensi Graph Tree Stack Queue Linear non linear Linked- List Graph (dinamis) Non Linear Tree Graph

  3. A B C D E F G H I J K L M N 5.1. Tree, M-ary Tree dan Binary Tree Gambar-5.1 Contoh sebuah TREE 179

  4. A B C D E F G H I J K L M N Gambar-5.1 a. Tree dan Graph T =  G Tree merupakan bagian dari Graph. 179

  5. v0 Gambar-5.1 e0 A e2 e1 v1 v2 v3 B C D e12 E F G H I v13 J K L M N b. Simpul (Vertex, Node), dan Busur (Edge, Arc) T = ( V,E) V = { v0, v1, v2, . . . . . . , v13 } E = { e0, e1, e2, . . . . . , e12 } 179

  6. A B C D E F G H I J K L M N Gambar-5.1 c. Superordinat dan Subordinat, Father dan Son Untuk contoh pohon diatas : Simpul B merupakan superordinat simpul E dan F. Simpul E dan F mempunyai superordinat yang sama yaitu simpul B. Simpul B mempunyai 2 subordinat yaitu simpul E dan simpul F 179

  7. A B C D E F G H I J K L M N Root Gambar-5.1 d. Akar (Root) dan Daun (Leaf/Leaves) Akar = Simpul yang tak mempunya superordinat. Daun = simpul yang tak mempunyai subordinat Dari pohon diatas : Akar = Simpul : A. Daun = Simpul : C, E, G, I, J, K, L, M, N 179

  8. A B C D E F G H I J K L M N Level Root 0 Gambar-5.1 e. Level dan Depth Tingkat dan Kedalaman 1 2 3 Depth = 3 Akar berada di Level : 0 Subordinat Level i adalah Level : i+1 179

  9. A B C D E F G H I J K L M N Gambar-5.1 f. Degree (Derajat) Simpul dan Degree Pohon Degree Simpul A = 3 B = 2 C = 0 Simpul daun, degree = 0 Degree Pohon : Untuk pohon ini degree pohon dapat diduga = 3, Tapi masih mungkin 4, 5 dan seterusnya Yang pasti bukan = 2 179

  10. Pohon M-Ary dan Pohon Binary 179

  11. Pohon M-Ary 1 2 3 4 5 dan setreusnya M = M menyatakan derajat pohon Khusus untuk M=2, Disebut Binary Tree (Pohon Biner) 179

  12. A A B B C E D F G H C I J K D Contoh sebuah TREE dengan derajat = 3 (3-Ary Tree) Gambar-5.2 b Gambar-5.2 a 179

  13. INFO Link1 Link2 Link3 Sebuah simpul pohon M-ary dimana M=3 digambarkan dengan Linked-List Strukturnya dapat dibuat dengan : typedef struct Node { int INFO; struct Node *Link1; struct Node *Link2; struct Node *Link3; }; typedef struct Node Simpul; Gambar-5.3 179

  14. Pohon Binary 179

  15. INFO LEFT RIGHT Sebuah simpul Pohon Biner digambarkan dalam bentuk Linked-List Strukturnya dapat dibuat dengan : typedef struct Node { struct Node *LEFT; int INFO; struct Node *RIGHT; }; typedef struct NodeSimpul; Gambar-5.4 atau typedef struct Node { int INFO; struct Node *LEFT; struct Node *RIGHT; }; typedef struct NodeSimpul;

  16. Root P 25 typedef struct Node { struct Node *LEFT; int INFO; struct Node *RIGHT; }; typedef struct NodeSimpul; Simpul *First, *Last, *P, *Q, *Root; // membuat Simpul Akar P = (Simpul * …………………); P->INFO = X; //misal X = 25 Root = P; P->Left = NULL; P->Right = NULL;

  17. A A A C B C B F D E F D E H I G H I G H H Contoh sebuah Pohon Biner Gambar-5.5 b Gambar-5.5 a Gambar-5.5 c 182

  18. A B C D 1 3 5 E F G H 6 9 11 14 I J 19 16 21 h. Link, Null-Link dan Bukan Null-Link Contoh Soal. Soal-1. Sebuah pohon M-ary dengan 10 buah simpul Bila M = 3 , maka Ditanya berapa jumlah Null-Link: Gambar 5.6 a 179

  19. 1 2 3 4 5 A 7 B C 9 D E 11 F G 13 H J 15 J 17 21 19 Gambar-5.6 b Pohon 3-ary Skewed Right (Skewed to the right) 179

  20. A 1 2 3 B C D 4 5 A 1 3 5 7 B E F G H C 9 D E 6 9 11 14 11 F I J G 13 H J 19 16 21 15 J 17 21 19 Jawab : Pohon dengan M = 3 Jumlah simpul 10, jadi : n = 10 Jumlah Null-Link = n * (M-1) + 1 = 10 * (3-1) + 1 = 10 * 2 + 1 = 21 179

  21. A A 1 B B C 2 C 3 1 D D E F 4 E 2 3 4 G H I 5 F 8 6 7 G 9 5 6 H 7 H 8 I 10 11 9 J 10 11 Soal-2. Sebuah Pohon Biner dengan 10 buah simpul Ditanya berapa jumlah Null-Link:

  22. A B C 1 D E F 2 3 4 G H I 8 7 9 5 6 H 10 11 Soal-2. Sebuah Pohon Biner dengan 10 buah simpul Ditanya berapa jumlah Null-Link: Jawab : Pohon Biner, berarti M = 2 Jumlah simpul 10, jadi : n = 10 Jumlah Null-Link = n * ( M - 1 ) + 1 = 10 * ( 2 - 1 ) + 1 = 10 * 1 + 1 = 11

  23. A Level 0 B C D 1 2 E F G H I 3 J K L M N Depth = 3 5.2 Konversi Pohon M-ary ke Pohon Biner Soal : Konversikan pohon M-Ary berikut ini menjadi Pohon Biner

  24. A A B B C D E C E F G H I F D J G J K L M N K H A L M I B C D N E F G H I J K L M N Level 0 Level 0 1 2 1 2 3 3 4 5 6 Gambar-5.10 c Pohon Biner hasil konversi dari pohon M-ary Gambar-5.10 a Bentuk Transformasi belum membentuk Pohon Biner 186

More Related