Download presentation
Presentation is loading. Please wait.
Published byLiliana Cain Modified over 9 years ago
1
10.3 Tree Transversal
2
Pre/post fix notation and order See handout. a.bc.d e f g h i j k
3
Preorder transversal- root first, then left to right a.bc.d e f g h i j k
4
Inorder transversal- left tree, then root, then rest of trees- left to right a bc d e f g h i j k
5
Postorder transversal- left to right, then root last a.bc.d e f g h i j k
6
Infix, prefix, and postfix See handout Infix order is ambiguous – so parentheses are required Prefix and postfix are not– so parentheses are unnecessary Prefix- “Polish notation” – Read from R to L – Operations are on the L Postfix – Read from L to R – Operations are on the R
7
Example– transverse in 3 ways, and evaluate each notation + * 32 5 2 Preorder- prefix Inorder-infix Postorder-postfix
8
Example- prefix Evaluate a prefix expression + - * 2 3 5 / 2 3 4
9
Ex- postfix 7 2 3 * - 4 9 3 / +
10
Example– transverse in 3 ways, and evaluate each notation + * 52 3 4 Preorder- prefix Inorder-infix Postorder-postfix - *
11
Find the value of each prefix expression (R to L,operations on the L) - * 2 / 8 4 3 - * 3 3 * 4 2 5
12
Find the value of each prefix expression (R to L,operations on the L) + - 3 2 2 3 / 6 – 4 2 * + 3 + 3 3 + 3 3 3
13
Find the value of each postfix expression (L to R, operations on R) 5 2 1 - - 3 1 4 + + *
14
Find the value of each postfix expression (L to R, operations on R) 9 3 / 5 + 7 2 - * 3 2 * 2 5 3 – 8 4 / * -
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.