Sunday, March 23, 2014

Tree & Binary Tree

I. Tree Concept





II. Binary Tree concept

parent punya 2 anak
















Beda Binary Tree dan Binary Search Tree






Boleh memasukan angka berapa pun secara acak







B -> harus lebih kecil dari A
C-> harus lebih besar dari A












III. Type of Binary Tree


Perfect Binary Tree
>di paling bawah full
>tiap level jumlahnya sama










Complete Binary Tree
> Bawahnya tidak full  

















IV. Expresion Tree Concept


prefix : * + ab /- cde    --> tanda di depan
postfix : ab + cd - e /*  --> tanda di belakang
infix : (a+b)*((c-d)/e)    --> tanda di tengah

contoh 1 :
2 + a + (b/2) * 3
prefix = + 2 + a / b 2 3
postfix = 2 ab 2/3 * ++

contoh 2:
3 / (a +b) -2
prefix = - / 3 + ab 2
postfix = 3 ab + / 2


bedanya graph dan tree


graph : ujung tersambung







Tree : ada yang digantung










V. Menggambar Tree

c / a * 2 + 3 / 12 + 21



cara untuk mengecek :
infix     : L V R
postfix : L R V
prefix   : V L R














No comments:

Post a Comment