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
2
votes
1 answer

I am trying to understand my homework, java Lisp arithmetic expression

I am trying to understand what exactly is being asked of me, and maybe you can give me some intuition into how to think about solving this problem. I need to write a program in Java that evaluates a Lisp arithmetic expression but the solution has to…
kolonel
  • 1,412
  • 2
  • 16
  • 33
2
votes
1 answer

How to find the next token of a String

I am working on a program that solves arithmetic equations. An example of an equation would be: 4+(5/4)+3/((5/3-2.4(*(5-7)) I have a program that converts this equation from infix to postfix form but the program is messing up with the decimal in…
user2932450
  • 71
  • 1
  • 2
  • 12
2
votes
1 answer

First Java Data Structures Assignment

edit - I revised my code and replaced my original work with new code, still having similar issues This data structures class I'm taking is my first programming course, so I'm a bit out of my element. The first project is really kicking my ass. It is…
Lunch
  • 57
  • 1
  • 1
  • 7
2
votes
3 answers

Postfix Notation calculation program in C, having some problems

I'm attempting to create a program to run calculations in postfix notation using C, and reading in values from the unix command line. I, however, am quite new to the C language, and am having a bit of trouble getting things to work correctly. I'm…
Ranma344
  • 169
  • 1
  • 8
2
votes
1 answer

Arithmetic Expression Evaluation in j2me: Works only for single digit operands

I have implemented the algorithm that I have found on this link to evaluate an arithmetic expression for j2me. But it works fine only when I have single digit operands i.e. 2, 5, 7, 3 but not for 456, 56, 34.45 etc. I did some changes as i knew i…
Nitesh Verma
  • 1,795
  • 4
  • 27
  • 46
2
votes
1 answer

In Erlang, how to return a string when you use recursion?

I really could'n formulate the question better, but here's my problem: I want to use this code to convert infix expression to postfix expression in Erlang, but it only writes to the console output. The problem is, I need a list or a string returned,…
A B
  • 23
  • 2
2
votes
2 answers

Refactoring feedback for Reverse Polish Notation (RPN) or Postfix Notation

One of the pre-work exercises for Dev Bootcamp is an RPN calculator. I made it work but would like refactoring feedback. Any and all help to make this code cleaner is greatly appreciated. class RPNCalculator def evaluate(rpn) a =…
ltrainpr
  • 3,115
  • 3
  • 29
  • 40
2
votes
1 answer

Calculate negatives in the stack calculator

Bear with me, I'm a little fried right now from getting this all together, but I'm at the final stretch. I've made a calculator in java that takes an infix equation and then changes it to postfix. It also takes variables! I'm made it so my postfix…
Ryan Tibbetts
  • 412
  • 1
  • 8
  • 22
2
votes
1 answer

Recognizing negative values when converting infix to postfix

This is my class: import java.io.*; import java.util.*; import java.lang.*; import java.util.Scanner; import java.util.List; import java.util.Stack; /** * * @author rtibbetts268 */ public class InfixToPostfix { /** * Operators…
Ryan Tibbetts
  • 412
  • 1
  • 8
  • 22
2
votes
4 answers

infix to postfix converter

I have been working on this infix to postfix/polis notation converter. Although, I do not feel the solution is adequate. Specifically the j (EDIT: Now called index) variable is bugging me. Do you guys have any suggestions? Or perhaps there is a much…
CasperT
  • 3,425
  • 11
  • 41
  • 56
2
votes
4 answers

what is benefits for changing from infix to postfix?

I read book today. It introduced algorithm about chaning from infix to postfix.. What is benefits? Thanks in advance.
user1705636
  • 233
  • 1
  • 6
  • 14
2
votes
1 answer

ANTLR Expression List Conflict

Here is a basic structure for simple nested expressions... infix : prefix (INFIX_OP^ prefix)*; prefix : postfix | (PREFIX_OP postfix) -> ^(PREFIX_OP postfix); postfix : INT (POSTFIX_OP^)?; POSTFIX_OP : '!'; INFIX_OP : '+'; PREFIX_OP :…
2
votes
1 answer

Why is my print function producing this error for my postfix program?

I am trying to write a program to calculate postfix expressions, it includes both a driver and an implementation file. These two shown below: #include #include #include #include "Stack.h" using namespace std; void…
1
vote
2 answers

Debugging postfix calculator

My task is to build a postfix calculator using a linked list to represent the stack. I have written the following code for the calculator, however I am receiving a compiler error that I do not understand. The error is coming from the postfixcalc.cpp…
Eric
  • 55
  • 1
  • 6
1
vote
1 answer

Infix to Postfix to Output (Postfix Calculator) using stacks

Good day, everyone! I'm new in C++ (and here in stackoverflow as well) and I need help from you experts. I have here a code that should ask the user for the infix expression then converts it to postfix and outputs the result (postfix calculator).…
First Lady
  • 79
  • 2
  • 3
  • 15