130 likes | 290 Views
Chapter 9 “ Tree graphs ”. Tree. it is graphs it have edeges and vertices but has no cycles. Traversal Tree There are 3 standard ways of traversing a tree with root R. In order traversal. Pre order traversal. Post order traversal. example: Apply traversal to print the tree:. a. b.
E N D
Chapter 9 “Tree graphs”
Tree it is graphs it have edeges and vertices but has no cycles
Traversal Tree There are 3 standard ways of traversing a tree with root R. In order traversal Pre order traversal Post order traversal
example: Apply traversal to print the tree: a b c d e f g h
solution: • (1) In order traversal: Left : h d b e .Root : a .Right : f c s .The result : h d b e a f c g .
(2) Pre order traversal :- Root : a . Left : b d h e . Right : c f g . The result : h d e b f g c a .
(3) Post order traversal:- Left : h d e b . Right : f g c . Root : a . The result : h d e b f g c a .
Building Tree : • example: • Building trees with the data set … • (1) 50 , 60 , 40 , 30 , 20 , 45 , 65. • . (2) 10 , 20 , 30 , 40 , 50
solution: (1) Step1 Step2 Step3 Step4 50 50 50 50 40 60 60 60 40 30
step 5 step 6 step 7 50 50 50 40 60 40 60 40 60 30 30 45 65 30 45 20 20 20
solution: (2) Step 1 Step 2 Step 3 Step 4 10 10 10 10 20 20 20 30 30 40
Step 5 10 20 30 40 50
عمل الطالبات : • سارة مبارك • مها مبارك • فاطمة مبارك • هيا فهد • غزاله ناصر • ريم عبد الله • نوره محمد • وفاء حمد