Thread: Shunting-yard algorithm

  1. #1
    Registered User
    Join Date
    Dec 2012
    Posts
    61

    Shunting-yard algorithm

    Can I use Shunting-yard algorithm to evaluate Expressions (arithmetic, relational, and logical) ?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    No, but you can use it as part of an algorithm to evaluate such expressions that are in infix notation.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Dec 2012
    Posts
    61
    Is this want you mean @laserlight? The accepted answer in the link..
    parsing - Shunting yard algorithm for immediate evaluation - Stack Overflow

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Yes.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Dec 2012
    Posts
    61
    Can I evaluate it with this expression?

    Code:
    (1 + 2) > 3 && 1 < 3

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    What is the Shunting Yard algorithm?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  7. #7
    Registered User
    Join Date
    Dec 2012
    Posts
    61
    Quote Originally Posted by laserlight View Post
    What is the Shunting Yard algorithm?
    Yes.

  8. #8
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    I asked you what, so a yes/no answer does not make sense. Have you actually looked at the Shunting Yard algorithm? Try implementing it for simple arithmetic expressions (e.g., using the algorithm pseudocode given in the Wikipedia article for reference). When you have done so, then come back and ask these questions, if you haven't figured them out yourself.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  9. #9
    Registered User
    Join Date
    Dec 2012
    Posts
    61
    Okay, thanks..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Shunting-Yard Algorithm
    By jwroblewski44 in forum C Programming
    Replies: 8
    Last Post: 04-06-2013, 01:45 PM
  2. Implementing the Shunting Yard Algorithm
    By manasij7479 in forum C++ Programming
    Replies: 0
    Last Post: 03-01-2011, 04:01 AM
  3. More help needed w/ Shunting Yard Algorithm
    By P4R4N01D in forum C Programming
    Replies: 3
    Last Post: 12-02-2008, 05:13 PM
  4. Shunting yard algorithm.
    By Homunculus in forum C++ Programming
    Replies: 1
    Last Post: 05-01-2008, 02:41 AM
  5. Shunting Yard Algorithm
    By EvilGuru in forum C Programming
    Replies: 3
    Last Post: 11-04-2005, 01:20 PM