Senin, 09 Februari 2015

Contoh Soal Binary Tree

Contoh soal

Tree 1


Tree 2

Tree 3
  1. Tentukan root masing masing tree
  2. tentukan leaf masing masing tree
  3. rubahlah menjadi binary tree
  4. tentukan Height dan Width
  5. dari ke 3 tree tersebut rubahlah menjadi binary tree
  6. dari soal diatas bentuklah 3 aktifitas dalam binary tree
  • Pre order
  • In order
  • Post order
jawaban
1. tree 1 = A, tree 2 = 1, tree 3 =A1
2.tree 1 = (W,P,R,S,Z,H,I,J,U,V,X,L,Y,N,O)
   tree 2 = (3,4,7,8,9,10)
   tree 3 = (A4,A5,A6)
3. Tree1
Tree2
Tree3
4. Tree 1 Height = 6
               Widht = 15
    Tree 2 Height = 5
               Width = 6
    Tree 3 Height = 4
               Width = 3
5.  


6. Tree 1 
    Pre order Transversal   = A B W G H I P Q R S T Z C J K U V X D L E M N Y F O
    In Order Transversal    = I H G P Q R S T Z A B W C J K U V X D L E M N Y F O
    Post Order Trensversal =  I Z T S R Q  P G W B X V U K N Y M L J O FE D C A
  Tree 2 
    Pre order Transversal   = 1 2 3 4 5  6 7 8 9 10
    In Order Transversal    = 7 6 8 9 10 1 4 5 3 2
    Post Order Trensversal =  7 6 8 9 10 4 5 3 2 1
 Tree 3 
    Pre order Transversal   = A1 A2 A3 A4 A5 A6
    In Order Transversal    = A6 A5 A4 A3 A1 A2
    Post Order Trensversal = A6 A5 A4 A3 A2 A1

Tidak ada komentar:

Posting Komentar