1
COMP 250
Lecture 19
binary trees, expression trees
- Oct. 24, 2016
expression trees Oct. 24, 2016 1 Binary tree: each node has at - - PowerPoint PPT Presentation
COMP 250 Lecture 19 binary trees, expression trees Oct. 24, 2016 1 Binary tree: each node has at most two children. 2 Maximum number of nodes in a binary tree? Height (e.g. 3) 3 Maximum number of nodes in a binary tree? Height
1
2
3
4
5
6
7
preorder(root){ if (root is not empty){ visit root for each child of root preorder( child ) } }
8
preorderBT (root){ if (root is not empty){ visit root preorderBT( root.left ) preorderBT( root.right ) } } preorder(root){ if (root is not empty){ visit root for each child of root preorder( child ) } }
9
10
a b c d e f g
11
statement if boolean then statement else statement end
12 statement if boolean then statement else statement end if boolean then statement else statement end if boolean then statement else statement end
13
14
15
16
17
18
Use one.
19
20
21
22
23
e f g / * a d + b c
24
25
(after Polish logician Jan Lucasewicz 1920’s)
5*4+3 ? 5 <enter> 4 <enter> * <enter> 3 <enter> + <enter> No “=“ symbol needed