Tugas struktur data dari Bpk. Satrum Cahyono, Dosen STMIK ASIA MALANG.
PERTANYAAN:
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
Tree 2
Tree 3
4. Tree 1 Height = 6
Width = 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
0 komentar:
Posting Komentar