Is this Tree of Algebraic Expression Correct?

  • Context: MHB 
  • Thread starter Thread starter Brian82784
  • Start date Start date
  • Tags Tags
    Expression Tree
Click For Summary

Discussion Overview

The discussion revolves around the construction and evaluation of trees representing a specific algebraic expression. Participants are examining the correctness of their trees and the results of various tree traversal methods (preorder, inorder, postorder). The focus is on the representation of the expression and the implications of operator precedence.

Discussion Character

  • Exploratory, Technical explanation, Debate/contested, Mathematical reasoning

Main Points Raised

  • Some participants present two trees for the same algebraic expression and express uncertainty about their correctness.
  • One participant suggests that both trees could be correct but emphasizes the importance of including parentheses in the trees.
  • Another participant confirms the results of tree traversals for one of the trees and expresses agreement with the findings.
  • Some participants argue that one tree is correct while the other is incorrect, providing specific evaluations of the expressions represented by each tree.
  • There is a discussion about the operator precedence and how it affects the evaluation of the expression, with references to the "biggest" operator being evaluated last.
  • One participant mentions using Reverse Polish Notation and a calculator to assist in understanding the expression.
  • Another participant seeks confirmation on the correctness of their traversal results for the tree deemed correct by others.

Areas of Agreement / Disagreement

Participants express disagreement regarding the correctness of the two trees, with some asserting that one tree is correct and the other is not. There is no consensus on the overall correctness of the trees, as multiple views are presented.

Contextual Notes

Limitations include potential misunderstandings of operator precedence and the representation of the algebraic expression in tree form. The discussion does not resolve these issues definitively.

Brian82784
Messages
19
Reaction score
0
Hello I just wanted to see if I did this right. I've come up with two trees and I'm pretty sure one of them is correct, I'm just not sure.

Construct the Tree of the algebraic expression:
((x - 2) + 3) / ((2 - (3 + y)) x (w - 8))
 

Attachments

  • Tree.jpg
    Tree.jpg
    5.9 KB · Views: 128
  • tree2.jpg
    tree2.jpg
    5.7 KB · Views: 140
Last edited:
Physics news on Phys.org
Kristen said:
Hello I just wanted to see if I did this right. I've come up with two trees and I'm pretty sure one of them is correct, I'm just not sure.

Construct the Tree of the algebraic expression:
((x - 2) + 3) / ((2 - (3 + y)) x (w - 8))

Hi! :) I think that both of them are right,but it would be better to include also the parentheses of the algebraic expression at the trees,that you constructed.
 
Okay thank you. I also had to do this with one of the trees. So I picked the first tree. Does this look correct?

1) Show the results of performing a preorder search.
× ÷ + - X 2 3 - - 2 3 Y - W 82) Show the results of performing an inorder search.
X – 2 + 3 ÷ 2 – 3 – Y × W - 8 3) Show the results of performing a postorder search.
X 2 - 3 + 2 3 - y - ÷ W 8 - ×
 
Kristen said:
Okay thank you. I also had to do this with one of the trees. So I picked the first tree. Does this look correct?

1) Show the results of performing a preorder search.
× ÷ + - X 2 3 - - 2 3 Y - W 82) Show the results of performing an inorder search.
X – 2 + 3 ÷ 2 – 3 – Y × W - 8 3) Show the results of performing a postorder search.
X 2 - 3 + 2 3 - y - ÷ W 8 - ×

I also tried it,and found the same result as yours!It should be right! (Nod) (Yes)
 
The one on the right is correct, the one on the left is incorrect. The one on the left is evaluating the expression $\dfrac{(x-2)+3}{(2-3)-y}(w-8),$ whereas the one on the right is evaluating the expression $\dfrac{(x+2)-3}{(2-(3+y)) \cdot (w-8)}$. You can see that in the left version, $w-8$ is in the numerator, whereas in the right version, $w-8$ is in the denominator.
 
So the one I did starting with Division is actually correct
 
Ackbach said:
The one on the right is correct, the one on the left is incorrect. The one on the left is evaluating the expression $\dfrac{(x-2)+3}{(2-3)-y}(w-8),$ whereas the one on the right is evaluating the expression $\dfrac{(x+2)-3}{(2-(3+y)) \cdot (w-8)}$. You can see that in the left version, $w-8$ is in the numerator, whereas in the right version, $w-8$ is in the denominator.

Oh,yes you are right! Sorry for assuming that the left tree is also right.. (Sadface)
 
Kristen said:
So the one I did starting with Division is actually correct

Right - the "biggest" mathematical operator is the last one you'd evaluate.

By the way, the only reason I can answer this question is that http://mathhelpboards.com/mathematics-software-calculator-discussion-29/hp-50g-1953.html?highlight=calculator, with Reverse Polish Notation (postfix notation) and a stack. That's a very nice combination, because it let's you play with calculations as you go.
 
So then would this be correct for the tree on the right?

1) Show the results of performing a preorder search.
÷ + - X 2 3 × - 2 + 3 Y- W 82) Show the results of performing an inorder search.
X – 2 + 3 ÷ 2 – 3 +Y × W - 8 3) Show the results of performing a postorder search.
X 2 - 3 + 2 3 y +- W 8 - ×÷
 
  • #10
Kristen said:
So then would this be correct for the tree on the right?
Yes, they seem correct.
 

Similar threads

  • · Replies 16 ·
Replies
16
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 19 ·
Replies
19
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 18 ·
Replies
18
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
1K
Replies
9
Views
2K