Trees
Download
1 / 22

TREES - PowerPoint PPT Presentation


  • 202 Views
  • Uploaded on

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.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'TREES' - gail-huber


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

Trees
Tree

  • Minimal Terdiri dari 1 node (simpul)

node

root

m – ary Tree

leaf

leaf

Branch


Binary tree

binary

Binary Tree

Binary juga disebut 2-ary Tree

Yaitu Tree dengan anak <=2


Representasi infix pada tree

+

A

B

Representasi Infix pada Tree

1. Infix A+B

2. Infix A * B ^ C – D

-

D

*

A

^

B

C


Representasi infix pada tree1

+

/

A

D

B

E

Representasi Infix pada Tree

3. Infix (A+B) * C + D / E

+

*

C


Tree level
Tree Level

  • Tree dibawah

N0

Level 0

N3

Level 1

N1

N2

Level 2

N5

N4

N6

N7

N8

N9

N10

N11

Level 3


Tree level1
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


Representasi tree

N0

N3

N1

N9

N8

N4

N5

N6

N10

N11

N2

N7

Representasi Tree

1. Diagram Venn


Representasi tree1
Representasi Tree

2. Pedigree Chart

N0

N3

N1

N2

N5

N4

N6

N7

N8

N9

N10

N11


Representasi tree2

N4

N5

N1

N6

N0

N2

N7

N10

N8

N3

N11

N9

Representasi Tree

3. Linear chart


Representasi tree3
Representasi Tree

4. Nested Parentheses

(N0(N1(N4)(N5)(N6))(N2(N7))

(N3(N8(N10)(N11))(N9)))


Representasi tree4

N0

N1

N4

N5

N6

N2

N7

N3

N8

N10

N11

N9

Representasi Tree

5. Bar Chart


Representasi tree5
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


General tree vs binary tree

A

A

B

B

A

A

=

B

B

General Tree Vs Binary Tree

  • General Tree

  • Binary Tree


Binary tree dalam array

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


Konversi general tree ke binary tree
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.


Konversi general tree ke binary tree1

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


Konversi general tree ke binary tree2

B

A

C

Y

H

Z

I

J

N

P

O

X

Konversi General Tree ke Binary Tree


Traversal pada binary tree

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


Traversal pada binary tree1

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


Traversal pada binary tree2

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


Trees
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