[Tutor] Binary tree expressions

Quiles, Stephanie stephanie.quiles001 at albright.edu
Wed Aug 19 17:09:44 CEST 2015


Yes I got the exact same thing. I figured it out once I sent the email. It is easier to start the tree from the bottom and work your way up than the way I was doing it which was from the top down. Thanks for your reply Alex, it was still helpful to get someone else's interpretation 



Stephanie Quiles
Sent from my iPhone

> On Aug 19, 2015, at 2:41 AM, Alex Kleider <akleider at sonic.net> wrote:
> 
>> On 2015-08-18 07:36, Quiles, Stephanie wrote:
>> Hello!
>> Not sure if anyone can help me with these or not but here it goes...
>> I have to draw an expression tree for the following (a+b)*c-(d-e).
>> I believe that the last move would go first in the tree so in this
>> case you would subtract c after computing what d-e was. So my tree
>> would start out looking like this :
>>     (-)
>>     / \
>>   (+)  (-)
>>   / \   / \
>> Sorry not sure how to better draw that...
>> Is that correct so far? Where do I go from there if I am? The c is
>> really throwing me off here.
>> Here's the other tree:
>> ((a+b) *c-(d-e)) ^ (f+g)
>> So for this one you would do everything in the double parentheses
>> first so a+b and d-e then multiple the sum of a+b by c
>> Then I would subtract c from the sum of d-e.
>> Then I would look at the right side and add f+g
>> Finally I would calculate the sum of the left side  ^ of the sum of f+g.
>> So my tree would start with the ^ its children would be * (left child)
>> + (right child)
>> Is that right so far?
> 
> Here's how I interpret the issue:
> 
> (a+b)*c-(d-e)
> 
> 
>            -
>          /   \
>         *     -
>        / \   / \
>       +   c d   e
>      / \
>     a   b
> 
> ((a+b) *c-(d-e)) ^ (f+g)
> 
>                ^
>             /     \
>            -       +
>          /   \    /  \
>         *     -  f    g
>        / \   / \
>       +   c d   e
>      / \
>     a   b
> 
> If I understand the problem correctly, it seems to be a test of your ability to understand precedence as in 'order of operation.'
> 
> Parentheses trump any of the following.
> ^ is highest of the ones involved here.
> * is next (as is division but that's not involved here)
> + and - are lowest.
> 
> Hope this helps.
> 
> 
> <bin_tree>


More information about the Tutor mailing list