c++ - How to write an evaluator for a string like "(1+3 * ( 5 / 4)) and get a numeric result -


This is an interview question, I'm confused about its solution, I'm thinking that pushing these operators And needing a pile to pop, Operand, but do I need two piles, operator for one more operand? Or just what a stack would be? I think we need two piles, but is there a way to use a stack?

I am also a little confused how this will work, every time I take an operator, two of my top operatives and press the result in the stamp

Prioritization is the first bracket , Then split, multiply and the last subtraction, and beyond that

But how to check for pop-ups do two operands and essential arthritic operations?

Take a look at this.

The Shunting Yard Algorithm is a method for parseing mathematical equations, which is specified in infix notation. It can be used to make output in reverse polish notation (RPN) or as an abstract syntax tree (AST). The algorithm was invented by Edsher Dijxtra and the name of the "Shunting Yard" algorithm was given because it operates like a rail shutting yard.


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -