0
0
PHPprogramming~5 mins

DNF types (Disjunctive Normal Form) in PHP - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is Disjunctive Normal Form (DNF) in logic?
DNF is a way to write logical expressions as an OR of ANDs. Each AND group contains only variables or their negations, and the whole expression is a combination of these groups connected by OR.
Click to reveal answer
beginner
How can DNF be useful in programming?
DNF helps simplify complex logical conditions by breaking them into simpler parts. This makes it easier to evaluate, optimize, or convert logic into code like PHP if-statements.
Click to reveal answer
beginner
In PHP, how would you represent a DNF expression like (A AND B) OR (NOT C AND D)?
You can use boolean operators: ($A && $B) || (!$C && $D). This matches the DNF structure of OR between AND groups.
Click to reveal answer
intermediate
What does it mean if a logical expression is not in DNF?
It means the expression might have ORs inside ANDs or other complex nesting. DNF requires the top-level operator to be OR, with AND groups inside.
Click to reveal answer
intermediate
Why might converting to DNF cause an expression to grow larger?
Because distributing AND over OR can duplicate parts of the expression, making it longer and more complex, especially with many variables.
Click to reveal answer
Which of the following is a valid DNF expression?
AA OR (B AND (C OR D))
BA AND (B OR C)
C(A AND B) OR (C AND NOT D)
DNOT (A OR B)
In PHP, which operator represents logical AND?
A||
B&&
C!
D==
What does the 'NOT' operator do in logical expressions?
ANegates or reverses the truth value
BCombines two expressions with OR
CCombines two expressions with AND
DChecks equality
Why is DNF useful in programming?
AIt simplifies evaluation by standardizing structure
BIt makes expressions harder to read
CIt removes all negations
DIt converts expressions to numbers
What happens when you convert a complex expression to DNF?
AIt always becomes shorter
BIt removes all variables
CIt becomes a single variable
DIt may become longer due to distribution
Explain what Disjunctive Normal Form (DNF) is and why it is useful in programming.
Think about how logic can be broken into simpler parts.
You got /3 concepts.
    Describe how you would write a DNF logical expression in PHP code.
    Remember PHP boolean operators.
    You got /4 concepts.