1 / 16

Binary Tree Traversal

Binary Tree Traversal. Definisi. Penelusuran seluruh node pada binary tree. Metode : Preorder Inorder Postorder. PreOrder Traversal. Preorder traversal Cetak data pada root Secara rekursif mencetak seluruh data pada subpohon kiri Secara rekursif mencetak seluruh data pada subpohon kanan.

joshua
Télécharger la présentation

Binary Tree Traversal

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. Binary Tree Traversal

  2. Definisi • Penelusuran seluruh node pada binary tree. • Metode : • Preorder • Inorder • Postorder

  3. PreOrder Traversal • Preorder traversal • Cetak data pada root • Secara rekursif mencetak seluruh data pada subpohon kiri • Secara rekursif mencetak seluruh data pada subpohon kanan

  4. a b c Preorder Example (visit = print) a c b

  5. a b c f e d j g h i Preorder Example (visit = print) a b d g h e i c f j

  6. / + * e f + - a b c d Preorder Of Expression Tree / * + a b - c d + e f Gives prefix form of expression!

  7. InOrder Traversal • Inorder traversal • Secara rekursif mencetak seluruh data pada subpohon kiri • Cetak data pada root • Secara rekursif mencetak seluruh data pada subpohon kanan

  8. a b c Inorder Example (visit = print) b a c

  9. a b c f e d j g h i Inorder Example (visit = print) g d h b e i a f j c

  10. Postorder Traversal • Postorder traversal • Secara rekursif mencetak seluruh data pada subpohon kiri • Secara rekursif mencetak seluruh data pada subpohon kanan • Cetak data pada root

  11. a b c Postorder Example (visit = print) b c a

  12. a b c f e d j g h i Postorder Example (visit = print) g h d i e b j f c a

  13. / + * e f + - a b c d Postorder Of Expression Tree a b + c d - * e f + / Gives postfix form of expression!

  14. Latihan Telusuri pohon biner berikut dengan menggunakan metode pre, in, post, dan level traversal.

  15. Latihan 1

  16. Latihan 2

More Related