The Computing Series

Exercises

Level 1 — Understand

  1. How many rows does a truth table require for each of the following? Do not compute the value — just write the expression. Then compute it.

    • 2 variables
    • 5 variables
    • 10 variables
    • n variables
  2. Build the complete truth table for (P OR Q) AND (NOT P OR R). Show all intermediate columns. There are 3 variables — how many rows?

  3. What is Disjunctive Normal Form? Given the truth table for XOR (P ⊕ Q), construct the DNF expression manually, without using the XOR symbol.

Level 2 — Apply

A function grant_access(is_authenticated, is_authorized, is_not_banned) should return True only when all three inputs are True, and False otherwise.

  1. Build the complete truth table. How many rows?

  2. From the truth table, construct the DNF expression.

  3. Simplify the DNF expression. What is the simplest equivalent boolean expression?

  4. A new requirement: “also grant access if the user is a superuser, regardless of ban status.” Introduce a 4th boolean is_superuser. How many rows does the new truth table have? Write the updated function.

Level 3 — Design

A deployment pipeline has 8 boolean gate conditions: tests_passed, lint_clean, security_scan_passed, staging_deployed, smoke_tests_passed, approval_received, change_window_open, no_active_incidents.

  1. How many input combinations exist? Is exhaustive testing feasible in a CI pipeline that runs in under 5 minutes?

  2. Identify which pairs of conditions are likely to be independent (do not interact). Which pairs are likely to interact? Justify your reasoning.

  3. Propose a testing strategy that achieves high confidence without exhaustive coverage. Explicitly name the AT9 tradeoff you are making and quantify the coverage gap (how many combinations are you leaving untested?).

  4. A colleague suggests replacing the 8 booleans with a PipelineState enum. Design the enum values. How many rows does the new “truth table” have? What does this gain and what does it lose? Use AT3 notation.

Read in the book →