Algorithm for evaluating nested logical expression

Posted by TravelingSalesman on Stack Overflow See other posts from Stack Overflow or by TravelingSalesman
Published on 2012-12-06T21:21:30Z Indexed on 2012/12/06 23:04 UTC
Read the original article Hit count: 368

I have a logical expression that I would like to evaluate. The expression can be nested and consists of T (True) or F (False) and parenthesis. The parenthesis "(" means "logical OR". Two terms TF beside each others (or any other two combinations beside each others), should be ANDED (Logical AND).

For example, the expression:

((TFT)T) = true

I need an algorithm for solving this problem. I thought of converting the expression first to disjunctive or conjunctive normal form and then I can easily evaluate the expression. However, I couldn't find an algorithm that normalizes the expression. Any suggestions? Thank you.

The problem statement can be found here: https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=2&category=378&page=show_problem&problem=2967

© Stack Overflow or respective owner

Related posts about algorithm

Related posts about tree