100% found this document useful (1 vote)
1K views13 pages

Inary REE: - Kelompok 8

The document discusses binary trees, including: - Binary trees have nodes with at most 2 child nodes called left and right subtrees. - Types of binary trees include full, complete, and skewed binary trees. - Common binary tree operations include create, search, insert, find, traverse, count, and determine height. - Binary tree traversal methods include pre-order, in-order, post-order, and level-order traversal. - An example program demonstrates implementing different traversal methods on a sample binary tree.

Uploaded by

Fanny Stephanye
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
1K views13 pages

Inary REE: - Kelompok 8

The document discusses binary trees, including: - Binary trees have nodes with at most 2 child nodes called left and right subtrees. - Types of binary trees include full, complete, and skewed binary trees. - Common binary tree operations include create, search, insert, find, traverse, count, and determine height. - Binary tree traversal methods include pre-order, in-order, post-order, and level-order traversal. - An example program demonstrates implementing different traversal methods on a sample binary tree.

Uploaded by

Fanny Stephanye
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

BINARY TREE

_Kelompok 8_
 Marzhelly Djuan Kristanta
 Filawaty
 Ardillah Sahi P
 Yuliani
 Reskiana
 Ali Sari
Pengertian Binary Tree
Sebuah tree dengan syarat bahwa tiap node hanya
boleh memiliki maksimal 2 subtree yang disebut
sebagai subpohon kiri(left subtree) dan subpohon
kanan (right subtree) dan kedua subtree tersebut
harus terpisah, atau dengan kata lain tiap node
dalam binary tree hanya boleh memiliki paling
banyak 2 child.
Jenis-jenis Binary Tree
 Full Binary Tree
 Complete Binary Tree
 Skewed Binary tree
Operasi-operasi Binary Tree
 Create (pohon = NULL;)
 Search
 Clear (pohon = NULL;)
 Empty
 Insert,
 Find (Syaratnya adalah tree tidak boleh kosong.)
 Traverse
 Count
 Height
 Find Min dan Find Max,
 Child
UPDATE

B C

UPDATE=E
INSERT F

D Nill
F
E
Binary Traversal
Binary Tree Traversal

Simpul Induk Simpul induk dikunjungi Simpul induk Simpul di level I


setelah semua simpul
dikunjugi sebelum anak kiri dikunjungi & dikunjungi setelah dikunjungi
simpul anak sebelum simpul anak anak-anaknya sebelum simpul
Level-order
Pre-order Traversal
dikunjungi In-order Traversal
kanan. Post-order Traversal
dikunjungi. i+1 dikunjungi.
Traversal
>>
>>
>>Level-Order
Post-Order
In-Order
Pre-OrderTraversal
Traversal
Traversal
D
A
E

C
B D
C
E

A
D
C D
C
B
E
CLEAR

Nill
A

B C

D E
Contoh Program Sederhana
program traversal;
uses crt;
var pilih,i :integer;
a :array[1..5] of char;
procedure MasukkanData;
begin
for i:=1 to 5 do
begin
write('Masukkan Data ke-',i,' : ' );readln(a[i]);
end;
end;
procedure PreOrder;
begin
gotoxy(56,4);writeln('= ',a[1],' =');
gotoxy(53,10);writeln('= ',a[2],' =');
gotoxy(60,10);writeln('= ',a[5],' =');
gotoxy(49,16);writeln('= ',a[3],' =');
gotoxy(55,16);writeln('= ',a[4],' =');
readln;
End;
procedure InOrder;
begin
gotoxy(56,4);writeln('= ',a[4],' =');
gotoxy(53,10);writeln('= ',a[2],' =');
gotoxy(60,10);writeln('= ',a[5],' =');
gotoxy(49,16);writeln('= ',a[1],' =');
gotoxy(55,16);writeln('= ',a[3],' =');
readln;
end;
procedure PostOrder;
begin
gotoxy(56,4);writeln('= ',a[5],' =');
gotoxy(53,10);writeln('= ',a[3],' =');
gotoxy(60,10);writeln('= ',a[4],' =');
gotoxy(49,16);writeln('= ',a[1],' =');
gotoxy(55,16);writeln('= ',a[2],' =');
readln;
end;
procedure LevelOrder;
begin
gotoxy(56,4);writeln('= ',a[1],' =');
gotoxy(53,10);writeln('= ',a[2],' =');
gotoxy(60,10);writeln('= ',a[3],' =');
gotoxy(49,16);writeln('= ',a[4],' =');
gotoxy(55,16);writeln('= ',a[5],' =');
readln;
end;
procedure Exit;
begin
pilih:=6;
end;
begin
repeat
clrscr;
gotoxy(45,1);writeln('Bentuk Binary Tree :');

gotoxy(56,3);writeln(' ===');
gotoxy(56,4);writeln('= =');
gotoxy(56,5);writeln(' ===');

gotoxy(53,9);writeln(' ===');
gotoxy(53,10);writeln('= =');
gotoxy(53,11);writeln(' ===');

gotoxy(60,9);writeln(' ===');
gotoxy(60,10);writeln('= =');
gotoxy(60,11);writeln(' ===');

gotoxy(49,15);writeln(' ===');
gotoxy(49,16);writeln('= =');
gotoxy(49,17);writeln(' ===');

gotoxy(55,15);writeln(' ===');
gotoxy(55,16);writeln('= =');
gotoxy(55,17);writeln(' ===');
gotoxy(54,12);writeln('/\');
gotoxy(53,13);writeln('/ \');
gotoxy(52,14);writeln('/ \');

gotoxy(58,6);writeln('/\');
gotoxy(57,7);writeln('/ \');
gotoxy(56,8);writeln('/ \');
writeln('1.Masukkan Data');
writeln('2.Pre-Order Traversal');
writeln('3.In-Order Traversal');
writeln('4.Post-Order Traversal');
writeln('5.Level-Order Traversal');
writeln('6.Exit');
write('Masukkan Pilihan : ');readln(pilih);
case pilih of
1:MasukkanData;
2:PreOrder;
3:Inorder;
4:PostOrder;
5:LevelOrder;
6:Exit;
end;
until (pilih=6);
readln;
end.
THANKS !
!

You might also like