Question: Solve this task in C + + Let a boolean expression have the following form: t , which is True; f , which is False;

Solve this task in C++ Let a boolean expression have the following form:
t, which is True;
f, which is False;
!(expr), which is the logical negation of the inner expression expr;
&(expr1, expr2,...), which is the logical AND of two or more expressions expr1, expr2,...;
|(expr1, expr2,...), which is the logical OR of two or more expressions expr1, expr2,...;
A.(1 point) Write a function that, given a boolean expression, returns its result. The calculation should only use a stack data structure. You are allowed to use helper functions. Examples:
!(f)=> true
|(f,t)=> true
&(t,f)=> false
|(&(t,f,t),!(t))=> false
B.(0.5 points) Given a queue of boolean expressions of the described form, write a function that finds how many of the expressions in the queue evaluate to true. The function should NOT destroy the queue and is NOT allowed to use additional data structures.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!