Questions tagged [postfix-notation]

Postfix notation (also known as Reverse Polish Notation, RPN) is a mathematical notation wherein every operator follows all of its operands, in contrast to Polish notation, which puts the operator in the prefix position.

Postfix notation (also known as Reverse Polish Notation, RPN) is a mathematical notation wherein every operator follows all of its operands, in contrast to Polish notation, which puts the operator in the prefix position.

Both and postfix notation have the advantage over infix notation that operator precedence is completely defined by the expression, without parentheses being required, which further implies that both can be evaluated linearly by machine instructions without parsing.

572 questions
1
vote
2 answers

Infix to postfix conversion using stacks (linked lists) in C++

Good day, everyone! I'm new in C++ (and here in stackoverflow as well) and I need help from you experts. There's something wrong with this code even if there is no error or warning. It just hangs whenever the program is being executed. The program…
First Lady
  • 79
  • 2
  • 3
  • 15
1
vote
1 answer

C++ Converting Postfix to infix

So i'm programming a cmd-based calculator in C++. I finished it, but i was wondering, after converting the infix to postfix, i have a queue called the postfix queue containing the operators/operands in correct order. How do I convert a postfix…
Richard
  • 5,840
  • 36
  • 123
  • 208
1
vote
1 answer

C++ Calculator using Stacks and Queues

I'm trying to understand a topic in class about using stacks and queues as a means of programming a calculator. I understand what infix and postfix expression is but how does it make it easier for a program to evaluate an expression and why are…
Richard
  • 5,840
  • 36
  • 123
  • 208
1
vote
1 answer

infix to postfix program not working

I am supposed to write a program to convert infix to postfix. It works for some, but other times not correctly. Especially on infix expressions containing parantheses. Could anyone give me a clue why this is wrong? For example, the infix…
user1175955
  • 21
  • 1
  • 2
1
vote
2 answers

Java Binary Expression Tree - Checking parenthesis in an expression

I coded up this program which will take an infix notation expression and build a binary tree from it. Right now the only input expression that actually works would be like 2 + 2. I can't seem to figure out at all how to make it handle parenthesis…
1
vote
2 answers

Evaluating Postfix Notation

I wrote a stack class to evaluate a postfix expression. I understand how to do it except for the order of it. Let's say I have a simple one like: A B - C + My only question is, would it be A - B, or B - A? I can't find any resource online that…
Chris
  • 7,270
  • 19
  • 66
  • 110
1
vote
2 answers

postfix -expression evaluation

I am trying to implement postfix-expression evaluation, here is my code: #include #include using namespace std; template < class T > class Stack { private: T * s; int n; public: Stack(int maxn) { s = new…
user466534
1
vote
2 answers

Unary negation ignored in user input in my pemdas calculator using python

I'm having issues with my PEMDAS calculator built in python. The issue that I'm encountering is mainly that I can't find a way to make my code recognize the "-" sign at the beginning of the user's input. So when a user submits an input like -5+5 ,…
Mave360
  • 11
  • 3
1
vote
1 answer

Recognizing Parenthesis in an Infix to Postfix Conversion

Here is a java class I had to make for my data structures class. I know that this is far from the best way to do the conversion, but it is off of the pseudo code he gave in class and is therefor what he is looking for. The only thing he left for us…
Nclay09
  • 51
  • 2
  • 5
1
vote
1 answer

Postfix to Infix notation conversion in C

I am having a problem converting from postfix to infix in C. I know where the problem is, but I don't know how to fix it. #include #include #include struct Stack { int *T; int top; int capacity; }; void…
1
vote
0 answers

switch-statement gives correct output but if-else doesn't

I was solving a question where the task is to evaluate the postfix expression and find the final value. this is my solution code public static int evaluatePostFix(String S) Stack s = new Stack<>(); int n = S.length(); …
1
vote
1 answer

Code to convert infix to postfix is not working in case of a+(b-c)*d$e/f+g$(h-i) as input

#include #include #include int n; int stackfull(int top) { if(top==n) { return 1; } else { return 0; } } int stackempty(int top) { if(top==-1) { return 1; } …
1
vote
0 answers

RPN to infix with both numbers and pronumerals in Python

I am making a Python program where I get an RPN expression separated by spaces and convert it to infix. It should work like this: Input RPN: x 2 ^ 3 - 1 2 x * - * Output : -2x^3 + x^2 + 6x - 3 However, I cannot get it to work with both pronumerals…
1
vote
1 answer

Android Studio Java infix to postfix calculations decimal point gives crash

I was trying to make a calculator for my university homework. to calculate the results I use infix to postfix convention. but this code doesn't take only decimal point (.) as a result, it crashes whenever I put (.) as input like 1.1+ it crashes. In…
1
vote
0 answers

Convert infix to postfix which make use of user defined functions

What would be a good algorithm to convert infix to postfix of an expression which uses user-defined functions: For example: def get_random_integer(a, b, c): import random return random.choice([a,b,c]) # Expression to be…