00:01
We're given expressions in part a and we're after representing expressions using binary trees.
00:10
So we're given the expressions x plus x, y plus parentheses x divided by y, and x plus parentheses x, y plus x, parentheses, divided by y parentheses.
00:37
So first, i'll be with the first of these expressions, which was x plus xy plus x divided by y well one thing to recognize immediately the tree is the xy is in abbreviation for x multiplication y and so not only we have that you can also think of this as being an informal set of current distance here as well so first we're going to start with the tree for the subtree for x multiply y the multiplication as the root with children x and y.
01:38
And we also have the subtree for x divide y.
01:41
So division as the root with children, x and y.
01:49
And from our first subtree, we'll create a subtree for the expression x plus x times y.
01:57
This is going to be a subtree with addition as the root.
02:03
And we'll have x as one of the children.
02:08
The other children will be multiplication.
02:11
Multiplication will have the children x and y.
02:13
This is the other subtree we used.
02:18
And finally, combining this third subtree and the second subtree together, we can form a subtree for the entire expression.
02:28
So we have addition as the root.
02:33
And for children, we have the subtree, the third sub tree on the left.
02:39
We have another edition with children x and multiplication, which has children x and y.
02:53
And the other child of the first edition is going to be division, which has children x and y.
03:02
And so this is the binary tree representing this expression.
03:15
Now likewise, for the expression x plus xy plus x over y, here we go.
04:01
Recognize it again.
04:03
We have a native multiplication symbol here, as well as these parentheses.
04:09
And several go these subtree.
04:12
First thing is the subtrees for x times y.
04:15
This is simply multiplication is root with children x and y.
04:21
Then the form of a subtree for x times y plus x.
04:24
So this has addition as the root, and then the children.
04:30
On the left hand, we have our subtree, so multiplication with children, x and y.
04:37
And on the right side we have x as a child.
04:45
And then we'll form the subtree for x times y plus x divided by y.
04:52
So we'll use division as a root.
04:55
On the left, we have our subtree addition with children multiplication x, multiplication has children x and y.
05:09
And on the right, we have the child y.
05:17
And so, you can form the tree for this whole expression by using this subtree.
05:24
So we have addition of the root.
05:26
On the left we have x as a child, and on the right we have the subterated child.
05:31
So we have division with children addition and y.
05:39
Edition has children multiplication and x.
05:46
Multiocation has children x and y.
05:51
And so this is the tree representing this second expression.
06:00
So these are answers to part a.
06:02
Now, in part b, we're asked to write a.
06:06
Expressions using prefix notation so when writing prefix notation i'm going to use a shortcut here so for the first expression we want to make a prefix reversal of our first tree so we're going to start off by including what we'll move essentially counterclockwise like around the tree starting from the root and we're going to include each vertex exactly once and we'll include it as soon as we encounter it.
06:52
So we start with the addition, followed by another addition, followed by an x, followed by a multiplication, followed by an x, followed by a y, and we'll all right back up, followed by a division, followed by an x, and followed by a y.
07:21
And that's all the symbols.
07:23
So this is our first expression in pre -tech notation.
07:30
For the second expression, we'll do the same thing to the second tree.
07:41
So we begin with our root addition, and then we encounter clockwise, we encounter x, then we encounter division, then addition, then multiplication, then x, then y, we've already encountered multiplication and addition, then x, already encountered addition, you've already encountered a division, then y.
08:21
You've already encountered division, and we're back to our root division.
08:25
So this is our second expression, the prefix notation...