Question
Answered step-by-step
1. Write the truth table for boolean expression, p1 || (!(p2 && p3) && p4).
2. Write the expression (prove with truth table) to build a ham sandwich with or without egg.
p1, egg
...
Question
Answered step-by-step
1. Write the truth table for boolean expression, p1 || (!(p2 && p3) && p4).
2. Write the expression (prove with truth table) to build a ham sandwich with or without egg.
p1, egg
p2, ham
p3, bread
For example, expression, (p2 && p3 && ~p1), will build a ham sandwich without egg
Reference:
Not operation, !
true -> !(true) -> false
false -> !(false) -> true
Comparator,
age = 24
age > 18 -> 24 > 18 -> true
!(24 > 18) -> !(true) -> false
age = 17
age > 18 -> 17 > 18 -> false
!(false) -> true
age <= 18 -> 17 <= 18 -> true
weight = 140
(weight < 140) -> 140 < 140 -> false
AND Operation, &&
age = 24, weight =140
(age > 18) && (weight < 140) -> (24 > 18) && (140 < 140) -> true && false -> false
Truth Table, variables (true/false), all combination of possible conditions.
p1, p2 -> 2 boolean variable, the total possible combination will be 2^2 = 4
p1, p2, p3 -> 2 boolean variable, the total possible combination will be 2^3 = 2*2*2 = 8
p1, p2,...pn -> n bollean variable, the total possible combination will b 2^n
p1 p2 p1 && p2
0 0 0
0 1 0
1 0 0
1 1 1
p1 && p2 && p3 -> (p1 && p2) && p3
p1 p2 p3 (p1 && p2)->x (x && p3)
0 0 0 0 0
0 1 0 0 0
1 0 0 0 0
1 1 0 1 0
0 0 1 0 0
0 1 1 0 0
1 0 1 0 0
1 1 1 1 1
OR operation,
age = 24, weight =140
(age > 18) || (weight < 140) -> (24 > 18) || (140 < 140) -> true || false -> true
p1 p2 p1 || p2
0 0 0
0 1 1
1 0 1
1 1 1
p1 || p2 || p3 -> (p1 || p2) || p3
p1 p2 p3 (p1 || p2)->x (x || p3) p1 || p2 || p3 (lazy evaluation)
0 0 0 0 0 0
0 1 0 1 1 1
1 0 0 1 1 1
1 1 0 1 1 1
0 0 1 0 1 1
0 1 1 1 1 1
1 0 1 1 1 1
1 1 1 1 1 1
(p1 && p2) || p3
p1 p2 p3 (p1 && p2)->x (x || p3)
0 0 0 0 0
0 1 0 0 0
1 0 0 0 0
1 1 0 1 1
0 0 1 0 1
0 1 1 0 1
1 0 1 0 1
1 1 1 1 1
(p1 || p2) && p3
p1 p2 p3 (p1 || p2)->x (x && p3)
0 0 0 0 0
0 1 0 1 0
1 0 0 1 0
1 1 0 1 0
0 0 1 0 0
0 1 1 1 1
1 0 1 1 1
1 1 1 1 1
p3, bread
p1, egg
p2, ham
expression to build a sandwich, (p1 || p2) && p3
Cereal Milk, (C || M) && M
0 0 0
0 1 1
1 0 0
1 1 1
[Show More]