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

What type of algorithm is used for C# expressions?

Shunting-yard algorithm is used to convert expressions from infix to postfix notation (Reverse Polish notation), so that it is eaiser to evaluate them by a compiler. For example, 2 + 3 * 2 would be converted to 2 3 2 * +. In Wikipedia, it is…
user586399
3
votes
1 answer

Postfix to infix converter Objective C

I am trying to make an RPN calculator program and want to have a label which shows the expression you entered. If you enter 3,5,4,+,/ the label would show ((4+5) / 3). I am having trouble implementing this. I am using a mutableArray I call stack…
3
votes
1 answer

When are Scala Semicolons required

I am trapped at work with a locked down pc. But I am trying to practice my Scala. I am using Ideone.com since I can't even install scalac... Anyway this is not compiling: class DPt(var name: String, var x: Double, var y: Double){ def print…
matt walters
  • 591
  • 6
  • 14
3
votes
4 answers

conversion to proper postfix notation in minimum number of steps

An expression consisting of operands and binary operators can be written in Reverse Polish Notation (RPN) by writing both the operands followed by the operator. For example, 3 + (4 * 5) can be written as "3 4 5 * +". You are given a string…
Peter
  • 2,719
  • 4
  • 25
  • 55
2
votes
1 answer

Regular expression to split greedy but keep split token?

I have a string like: {A}{B}={C}{D}<{E}{F}<= What I want to do is split that string using a regular expression so as to get something like: 1: {A}{B}= 2: {C}{D}< 3: {E}{F}<= I'm currently splitting the string using…
2
votes
3 answers

Evaluating postfix expression using recursion

I need an algorithm for evaluating postfix expression using recursion. In this postfix expression an operand can be of more than one digit. A space is used to distinguish between two operands. So an expression '45 68 +' is valid. I thought of…
Keen Sage
  • 1,899
  • 5
  • 26
  • 44
2
votes
2 answers

Need help in implementing Java Algorithm on Postfix Evaluation

I've tried writing this code from scratch, coding, and running it but it just doesn't seem to work. This was assigned as lab work in class. The requirements are: Implementing a postfix evaluation with the use of a stack and stack operations…
user919789
  • 171
  • 4
  • 7
  • 19
2
votes
2 answers

Associativity rule in Infix to Postfix expression

My infix to postfix algorithm using stack: static int Prec(char ch) { switch (ch) { case '+': case '-': return 1; case '*': case '/': return 2; case '^': return 3; } return -1; } static String…
nehacharya
  • 925
  • 1
  • 11
  • 31
2
votes
1 answer

Copy-on-write for stacks

How to implement copy-on-write technique for stack management in postfix calculations of big numbers? I want to optimize my system regarding operations like: duplicate top of stack swap the two top elements copy the second element on stack to the…
Lehs
  • 812
  • 6
  • 18
2
votes
1 answer

Infix to Postfix form in Haskell

I'm a beginner in Haskell and i'm kind of lost on what to use to make this program work. What i have to do is get a String like this: "a+(b/c)" and turn it into its postfix form, which would be like this: "abc/+". The…
2
votes
1 answer

Evaluate Postfix Expression Tree - Calculator

I have code to generate a postfix expression from infix and generate an expression tree from the postfix notation. The problem is, if I give it an expression like 45 / 15 * 3, it will give me the result 1 instead of 9, because it is solving the…
biotecher
  • 159
  • 4
  • 14
2
votes
1 answer

R: getting if a value is between two dates and count

I have the following data frame in R df1 <- data.frame(id = c(12332, 231231, 123123, 1231231, 123123), date_in = c("04/08/2019 04:00", "04/08/2019 06:00", "05/08/2019 04:00", "08/08/2019 12:00",…
2
votes
1 answer

I need help to convert from infix to postfix in C

I was practising some data structures problems that I did previously but this time I don't know what is going wrong in my code. I looked over a long time but I did not found the mistake. When I'm printing I'm just getting the first character and it…
2
votes
0 answers

How to accept negative values in postfix expressions

Similar question has been asked here, However, still remains unanswered (at least no code provided, though the suggestion is good) My code unlike the hyperlinked one, only evaluates the entered expression I am not being able to fabricate a logic to…
user8704383
2
votes
1 answer

Testing for too many operands on C++ postfix to infix stack

I'm currently trying to test for if there are too many operands but cannot figure out the condition for when a postfix expression has too many operands. Could someone give me any pointers on what to test for? Here is my function so far: void…