3.6

Equivalent Expressions

AP Computer Science A

De Morgan's Laws

Visualizing De Morgan's Laws

Proof with truth tables

Applying De Morgan's Laws to code

Example 1: Negate a range check

Example 2: Negate an OR condition

Example 3: Negate a compound condition

Negating comparison operators

Step-by-step simplification

Equivalent if-else structures

Pair 1: Negating the condition, swapping branches

Pair 2: Combining conditions

AP exam practice problems

Problem 1 Which is equivalent to `!(a > b && c != d)`?

Problem 2 Which is equivalent to `!(x == 5 || x == 10)`?

Problem 3 Simplify: `!(!(done) && count < 10)`

Complete example: Equivalent conditions

AP Exam Tips

Common Mistakes

Key Vocabulary