Hrt / VO Interview Coding Question: Evaluate Boolean Expression

21 Views
No Comments

Evaluate Boolean Expression

Given a boolean expression containing the symbols T, F, &, |, ^, and parentheses, evaluate the expression and return its boolean result.

Example:

((T&F)|(T&F)) = F

This problem asks you to evaluate a boolean expression made of <code>T</code>, <code>F</code>, the operators <code>&amp;</code>, <code>|</code>, <code>^</code>, and parentheses. A typical solution uses recursion or a stack to handle nested subexpressions and applies the operator semantics correctly for AND, OR, and XOR. The key challenge is preserving parenthesis precedence while reducing each subexpression to a boolean value.

END
 0