Problem with evaluation expressions with exponents

Click For Summary
SUMMARY

The forum discussion centers on the evaluation of postfix expressions involving exponents, specifically using the example of the infix expression "3*(4^2-2/3)+4". The correct postfix conversion is "342^*23/-4+", which indicates that the exponentiation must be evaluated before multiplication and addition. The key takeaway is that proper order of operations is crucial when converting infix to postfix notation, particularly with expressions containing exponents.

PREREQUISITES
  • Understanding of infix and postfix notation
  • Knowledge of operator precedence and order of operations
  • Familiarity with exponentiation in mathematical expressions
  • Basic programming concepts related to expression evaluation
NEXT STEPS
  • Study the Shunting Yard algorithm for converting infix to postfix notation
  • Learn about operator precedence rules in programming languages
  • Explore expression evaluation techniques in languages like Python or Java
  • Investigate the implementation of a stack data structure for expression parsing
USEFUL FOR

Students, software developers, and computer science enthusiasts who are learning about expression evaluation and conversion techniques in programming.

nameVoid
Messages
238
Reaction score
0
The way i am evaluating post fix expressions is not working with exponents

Example
InfixII
3*(4^2-2/3)+4
To post fix
342^*23/-4+

=16*3-2/3)+4

Am i evaluating the parenthesis the wrong way
 
Physics news on Phys.org
Yes, you first need to evaluate 4^2 - 2/3. Then multiply that by 3.
 

Similar threads

  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 6 ·
Replies
6
Views
1K
  • · Replies 7 ·
Replies
7
Views
2K
Replies
9
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K