Question: In this problem, we consider logic expressions with the following operands and operators: Operands: 0 and 1, which represents false and true, respectively. Operators: &
In this problem, we consider logic expressions with the following operands and operators: Operands: 0 and 1, which represents false and true, respectively. Operators: & (and), | (or), and ! (not). Note that you also have to consider left and right parenthesis. The precedence of the three operators are ! > & > |.
(A)Draw the logical expression tree of the expression ! (0&! 1&0|0)&0. Since
! (not) is an unary operator, the only operand should be put to the right child of the operator. Write down its prefix expression.
(B)Please write down an algorithm to take a string of logic expression and convert it to an expression tree.
(C)Please write down an algorithm to evaluate the outcome of the logical expression using the tree generated by the algorithm in question (b)4(b). (Hint: Postorder traversal)
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
