12.5k views
4 votes
Assuming `weekday` and `holiday` are properly initialized booleans, which expression would be equivalent to the following: `!(weekday || holiday)`?

a) `!weekday && !holiday`

b) `weekday && !holiday`

c) `weekday || holiday`

d) `!weekday || !holiday

User YASH DAVE
by
7.1k points

1 Answer

2 votes

Final answer:

The expression equivalent to !(weekday || holiday) is !weekday && !holiday, following De Morgan's laws that translate the negation of a disjunction into a conjunction of negations.

Step-by-step explanation:

The expression that is equivalent to !(weekday || holiday) is !weekday && !holiday. The original expression uses the NOT operator (!) on the result of an OR (||) operation. By applying De Morgan's laws, which state that !(A || B) is equivalent to !A && !B, we can transform the original expression into one that uses AND (&&) and NOT (!) operators on the individual variables without changing the logical meaning of the expression.

The correct answer is option a) !weekday && !holiday. This is because the NOT operator negates the whole condition of it being either a weekday or a holiday, meaning it's neither a weekday nor a holiday.

User SFuller
by
7.5k points