00:04
We're given arithmetic expressions written in prefix notation, and we're asked to draw the ordered rooted tree corresponding to each of these expressions, and then we're asked to write each expression using infix notation.
00:23
So in part a, we're given the expression and prefix notation, addition, multiplication, addition, subtraction, 53214.
00:41
So to form the order of rooted tree, we're going to start with the addition as the root.
01:10
And then one of the children is multiplication.
01:15
And one of the children of multiplication is addition.
01:26
And one of the children of the addition is subtraction.
01:32
And then we have the children of subtraction are five and three.
01:37
And then we have the children of addition, our subtraction, and two.
01:47
And then we have the children of multiplication are addition and one.
01:55
And finally, we have that the children of addition are multiplication and four.
02:02
So this is the binary tree.
02:08
And using this tree, you can write the expression using infix notation.
02:12
So the way i like to do this is i go around the tree and counterclockwise.
02:15
Clockwise order.
02:17
First time i encounter a symbol that's not a leaf, i write a left parentheses.
02:23
The second time i encounter that symbol, i write the symbol, and the third time i encounter that symbol, i write a right parentheses.
02:32
So i have first i encounter addition as the root.
02:39
So i have a left parenthesis, then i encounter multiplication first time, left parentheses, then i encounter this edition the first time, another left parentheses.
02:49
Then i encounter subtraction for the first time, one more with left parentheses, then a five, which is a leaf.
03:04
So i'll rate a five since this is a leaf.
03:09
I encounter the subtraction for the second time, i write the subtraction.
03:12
Then i encounter three, a leaf.
03:14
Then i encounter subtraction for the third time, right parentheses.
03:19
Then i encounter addition for the second time, addition, then the leaf two, then addition for the third time, right parentheses, then multiplication for the second time, multiplication, then a one, a leaf, then multiplication for the third time, right parentheses.
03:40
And here i'm going to have to break this into two lines.
03:42
Then addition for the second time, addition, then the leaf four, and then the root addition for the third time, write parentheses.
03:54
And this concludes the infix notation for this expression.
04:03
So we have that, and we also have the tree.
04:09
Now, in part b, we are given the expression in prefix notation, exponentiation, addition to three, subtraction 5 -1.
04:33
So to construct the tree, i'm going to start with exponentiation as the root, which has children addition.
04:45
Well, it's one of the children.
04:46
And then we see addition has the children two and three, which are leaves.
04:54
And then we see that exponentiation also has the child in addition to addition of subtraction.
05:26
And subtraction has the children 5 and 1, which are leaves...