Binary tree traversal
This presentation is the property of its rightful owner.
Sponsored Links
1 / 16

Binary Tree Traversal PowerPoint PPT Presentation


  • 66 Views
  • Uploaded on
  • Presentation posted in: General

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.

Download Presentation

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Binary tree traversal

Binary Tree Traversal


Definisi

Definisi

  • Penelusuran seluruh node pada binary tree.

  • Metode :

    • Preorder

    • Inorder

    • Postorder


Preorder traversal

PreOrder Traversal

  • Preorder traversal

    • Cetak data pada root

    • Secara rekursif mencetak seluruh data pada subpohon kiri

    • Secara rekursif mencetak seluruh data pada subpohon kanan


Preorder example visit print

a

b

c

Preorder Example (visit = print)

a

c

b


Preorder example visit print1

a

b

c

f

e

d

j

g

h

i

Preorder Example (visit = print)

a

b

d

g

h

e

i

c

f

j


Preorder of expression tree

/

+

*

e

f

+

-

a

b

c

d

Preorder Of Expression Tree

/

*

+

a

b

-

c

d

+

e

f

Gives prefix form of expression!


Inorder traversal

InOrder Traversal

  • Inorder traversal

    • Secara rekursif mencetak seluruh data pada subpohon kiri

    • Cetak data pada root

    • Secara rekursif mencetak seluruh data pada subpohon kanan


Inorder example visit print

a

b

c

Inorder Example (visit = print)

b

a

c


Inorder example visit print1

a

b

c

f

e

d

j

g

h

i

Inorder Example (visit = print)

g

d

h

b

e

i

a

f

j

c


Postorder traversal

Postorder Traversal

  • Postorder traversal

    • Secara rekursif mencetak seluruh data pada subpohon kiri

    • Secara rekursif mencetak seluruh data pada subpohon kanan

    • Cetak data pada root


Postorder example visit print

a

b

c

Postorder Example (visit = print)

b

c

a


Postorder example visit print1

a

b

c

f

e

d

j

g

h

i

Postorder Example (visit = print)

g

h

d

i

e

b

j

f

c

a


Postorder of expression tree

/

+

*

e

f

+

-

a

b

c

d

Postorder Of Expression Tree

a

b

+

c

d

-

*

e

f

+

/

Gives postfix form of expression!


Latihan

Latihan

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


Latihan 1

Latihan 1


Latihan 2

Latihan 2


  • Login