Propositional and predicate logic
Unit I: Logic and sets · Topic 1 of 13
Key idea
A proposition is a sentence that is either true or false, never both. Connectives build compound propositions: not \(\lnot p\), and \(p \land q\), or \(p \lor q\), the conditional \(p \to q\) and the biconditional \(p \leftrightarrow q\). A truth table lists the value of a compound proposition in every one of its \(2^n\) rows, and two propositions are logically equivalent when their columns agree in every row. Predicate logic adds variables and quantifiers: \(\forall x\,P(x)\) says the property holds for every element of the domain, \(\exists x\,P(x)\) that it holds for at least one. Almost every proof in the course is an argument about implications and quantified statements, so this topic is the grammar for everything that follows.
Truth values. \(p \land q\) is true only when both are true; \(p \lor q\) is false only when both are false; \(p \to q\) is false only when \(p\) is true and \(q\) is false; \(p \leftrightarrow q\) is true when \(p\) and \(q\) agree. Exclusive or \(p \oplus q\) is true when they differ.
Rewriting a conditional.
\[p \to q \equiv \lnot p \lor q\] \[\lnot(p \to q) \equiv p \land \lnot q\] \[p \to q \equiv \lnot q \to \lnot p.\]English forms of \(p \to q\). “If \(p\) then \(q\)”, “\(p\) implies \(q\)”, “\(q\) if \(p\)”, “\(q\) whenever \(p\)”, “\(p\) only if \(q\)”, “\(p\) is sufficient for \(q\)” and “\(q\) is necessary for \(p\)” all mean the same thing. The traps: “\(p\) only if \(q\)” is \(p \to q\), not \(q \to p\); “\(p\) is necessary for \(q\)” is \(q \to p\); and “\(p\) unless \(q\)” is \(\lnot q \to p\). So “you pass only if you study” is \(\text{pass} \to \text{study}\), and “you pass unless you skip the exam” is \(\lnot\text{skip} \to \text{pass}\).
Named laws. De Morgan: \(\lnot(p \land q) \equiv \lnot p \lor \lnot q\) and \(\lnot(p \lor q) \equiv \lnot p \land \lnot q\). Distributive: \(p \land (q \lor r) \equiv (p \land q) \lor (p \land r)\) and \(p \lor (q \land r) \equiv (p \lor q) \land (p \lor r)\). Absorption: \(p \lor (p \land q) \equiv p\). Also the commutative, associative, idempotent (\(p \lor p \equiv p\)) and double negation laws.
Truth-table layout. List the \(2^n\) rows in a fixed order (for \(p, q\): TT, TF, FT, FF), add one column per subformula working from the inside out, and compare the final columns. For \(p \to q\) against \(\lnot q \to \lnot p\): the rows give T, F, T, T for both, so they are equivalent; the converse \(q \to p\) gives T, T, F, T, which differs in rows 2 and 3.
A tautology is true in every row, a contradiction in none, a contingency in some. \(p \equiv q\) means exactly that \(p \leftrightarrow q\) is a tautology.
- Negating quantifiers \(\lnot\forall x\,P(x) \equiv \exists x\,\lnot P(x)\) and \(\lnot\exists x\,P(x) \equiv \forall x\,\lnot P(x)\). Push the negation inward one quantifier at a time, flipping each.
- Order matters \(\forall x\,\exists y\,(x \lt y)\) is true over the integers (there is always a bigger one); \(\exists y\,\forall x\,(x \lt y)\) is false (no largest integer). In English: “every exam was passed by some student” is \(\forall e\,\exists s\,P(s, e)\), while “some student passed every exam” is \(\exists s\,\forall e\,P(s, e)\), a much stronger claim.
- Restricted domains “every prime \(p\) is odd” is \(\forall p\,(\text{Prime}(p) \to \text{Odd}(p))\), while “some prime is even” is \(\exists p\,(\text{Prime}(p) \land \text{Even}(p))\): a universal goes with \(\to\), an existential with \(\land\).
- Modus ponens from \(p\) and \(p \to q\) conclude \(q\). Modus tollens from \(\lnot q\) and \(p \to q\) conclude \(\lnot p\).
- Hypothetical syllogism \(p \to q\) and \(q \to r\) give \(p \to r\). Disjunctive syllogism \(p \lor q\) and \(\lnot p\) give \(q\).
- Fallacies affirming the conclusion (\(q\) and \(p \to q\), so \(p\)) and denying the hypothesis (\(\lnot p\) and \(p \to q\), so \(\lnot q\)) are not valid.
Checking an argument. Write each premise in symbols and chain the rules. “If it rains, the match is cancelled; if the match is cancelled, we go home; it is raining. Therefore we go home” is \(r \to c\), \(c \to h\), \(r\): hypothetical syllogism gives \(r \to h\), and modus ponens with \(r\) gives \(h\). Valid. By contrast “if it rains, the match is cancelled; the match is cancelled; therefore it rained” has the shape \(r \to c\), \(c\), hence \(r\): that is affirming the conclusion, invalid, because a cancelled match may have another cause.
Converse of \(p \to q\): \(q \to p\). Inverse: \(\lnot p \to \lnot q\). Contrapositive: \(\lnot q \to \lnot p\). Only the contrapositive is equivalent to the original; the converse and inverse are equivalent to each other.
How to work it
- Decide between a truth table (always works, \(2^n\) rows) and a chain of known equivalences (shorter, and required when the problem says “without truth tables”).
- For a chain, first eliminate \(\to\) and \(\leftrightarrow\): replace \(p \to q\) by \(\lnot p \lor q\) and \(p \leftrightarrow q\) by \((p \to q) \land (q \to p)\).
- Push negations inward with De Morgan and double negation until \(\lnot\) sits only on single variables.
- Apply the distributive, absorption and idempotent laws, naming each law on the line where you use it.
- For a quantified statement, negate by flipping every quantifier and negating the inside; then translate back into English and check that it says the opposite.
Show \((p \to q) \land (p \to r) \equiv p \to (q \land r)\) without a truth table.
\[(p \to q) \land (p \to r) \equiv (\lnot p \lor q) \land (\lnot p \lor r) \quad\text{(conditional law, twice)}\] \[\equiv \lnot p \lor (q \land r) \quad\text{(distributive law)}\] \[\equiv p \to (q \land r) \quad\text{(conditional law).}\]Each line names the law used, which is what a grader looks for. A truth table would confirm it in all eight rows.
Negate “every student in the class has taken some mathematics course.” With \(T(x, y)\) for “\(x\) has taken \(y\),” the statement is \(\forall x\,\exists y\,T(x, y)\), and
\[\lnot\forall x\,\exists y\,T(x, y) \equiv \exists x\,\forall y\,\lnot T(x, y)\]that is, “some student in the class has taken no mathematics course at all.” The quantifiers flip, their order stays the same, and the negation lands on the predicate.
Watch out. The conditional \(p \to q\) is true whenever \(p\) is false, whatever \(q\) says, and that single row is behind most truth-table errors; it also makes \(p \to q\) very different from its converse \(q \to p\). Keep the contrapositive \(\lnot q \to \lnot p\), which is equivalent, firmly separate from the converse and inverse, which are not, and never swap the order of \(\forall\) and \(\exists\) when negating.
Practice: problems 1, 2, 3, 4, 5, 6 (the practice groups are the last entries in the contents).
Sets, operations and cardinality
Unit I: Logic and sets · Topic 2 of 13
Key idea
A set is an unordered collection of distinct objects, written by listing, \(\{2, 4, 6\}\), or by a rule, \(\{x \in \mathbb{Z} : x \text{ is even}\}\). Everything about sets reduces to the membership question “is \(x\) in \(A\)?”, which is why set identities are proved by chasing elements and why the laws of set algebra are the laws of logic in different clothing: union is or, intersection is and, complement is not. Two sets are equal when each is a subset of the other. The cardinality \(|A|\) counts elements, and the rules for the size of a union, a product or a power set are the first real counting tools of the course.
Operations. Union \(A \cup B = \{x : x \in A \lor x \in B\}\); intersection \(A \cap B = \{x : x \in A \land x \in B\}\); difference \(A - B = \{x : x \in A \land x \notin B\}\); complement \(\overline{A} = U - A\); symmetric difference \(A \oplus B = (A - B) \cup (B - A)\); Cartesian product \(A \times B = \{(a, b) : a \in A,\ b \in B\}\).
Subsets. \(A \subseteq B\) means every element of \(A\) is in \(B\); \(A = B\) iff \(A \subseteq B\) and \(B \subseteq A\). The empty set \(\emptyset\) is a subset of every set. The power set \(\mathcal{P}(A)\) is the set of all subsets of \(A\).
For \(A = \{a, b\}\): \(\mathcal{P}(A) = \{\emptyset, \{a\}, \{b\}, \{a, b\}\}\), four subsets as \(2^2\) predicts; both \(\emptyset\) and \(A\) itself are members. With \(A = \{1, 2, 3\}\) and \(B = \{2, 3, 4\}\) inside \(U = \{1, \dots, 5\}\): \(A \cup B = \{1, 2, 3, 4\}\), \(A \cap B = \{2, 3\}\), \(A - B = \{1\}\), \(B - A = \{4\}\), \(A \oplus B = \{1, 4\}\), \(\overline{A} = \{4, 5\}\), and \(A \times B\) has \(3 \cdot 3 = 9\) ordered pairs, beginning \((1, 2), (1, 3), (1, 4), (2, 2), \dots\)
Identities. De Morgan: \(\overline{A \cup B} = \overline{A} \cap \overline{B}\) and \(\overline{A \cap B} = \overline{A} \cup \overline{B}\). Distributive: \(A \cap (B \cup C) = (A \cap B) \cup (A \cap C)\). Also \(A - B = A \cap \overline{B}\), absorption \(A \cup (A \cap B) = A\), and \(A \cap \overline{A} = \emptyset\).
Sets are unordered and ignore repeats: \(\{1, 2, 2\} = \{2, 1\}\). Ordered pairs are not: \((1, 2) \ne (2, 1)\).
- Power set \(|\mathcal{P}(A)| = 2^{|A|}\): each element is in or out of a subset.
- Product \(|A \times B| = |A|\,|B|\), and \(|A^n| = |A|^n\).
- Inclusion–exclusion \(|A \cup B| = |A| + |B| - |A \cap B|\), and for three sets \(|A \cup B \cup C| = |A| + |B| + |C| - |A \cap B| - |A \cap C| - |B \cap C| + |A \cap B \cap C|\).
- Difference \(|A - B| = |A| - |A \cap B|\); \(|\overline{A}| = |U| - |A|\).
- Disjoint sets \(A \cap B = \emptyset\), so \(|A \cup B| = |A| + |B|\) (the sum rule).
- Infinite sets \(\mathbb{Z}\) and \(\mathbb{Q}\) are countable (they can be listed \(a_1, a_2, \dots\)); \(\mathbb{R}\) is uncountable (Cantor’s diagonal argument). A set is countable iff it is finite or in bijection with \(\mathbb{Z}^+\). To prove a set countable, exhibit the list: \(\mathbb{Z}\) is \(0, 1, -1, 2, -2, \dots\), and the positive rationals are listed by walking the grid of fractions \(p/q\) diagonal by diagonal (\(\tfrac11, \tfrac12, \tfrac21, \tfrac13, \tfrac22, \tfrac31, \dots\)) and skipping repeats.
A Venn diagram for three sets has \(8\) regions; fill in the triple intersection first and work outward.
How to work it
- To show \(X = Y\), show \(X \subseteq Y\) and \(Y \subseteq X\), or use a chain of membership equivalences (“\(x \in X\) iff … iff \(x \in Y\)”).
- Take an arbitrary \(x \in X\) and unpack the definitions of the operations until you have a statement about \(x\) in propositional logic.
- Apply the logical law that matches (De Morgan, distributive) to the statement about \(x\).
- Reassemble the result into membership in \(Y\). If the chain used only “iff” steps, both inclusions are done at once.
- For a counting question, draw the Venn diagram or write inclusion–exclusion, and check that the regions add up to \(|U|\).
Show \(A - (B \cup C) = (A - B) \cap (A - C)\).
\[x \in A - (B \cup C) \iff x \in A \land \lnot(x \in B \lor x \in C)\] \[\iff x \in A \land (x \notin B) \land (x \notin C) \quad\text{(De Morgan)}\] \[\iff (x \in A \land x \notin B) \land (x \in A \land x \notin C) \iff x \in (A - B) \cap (A - C).\]Every step is an “iff,” so both inclusions hold and the sets are equal.
A one-direction inclusion is the same argument without the “iff”: to show \(A \cap B \subseteq A \cup B\), take \(x \in A \cap B\); then \(x \in A\) and \(x \in B\), so in particular \(x \in A\), hence \(x \in A \cup B\). The reverse inclusion fails in general (an element of \(A \cup B\) need not be in both), which is why the result is only \(\subseteq\).
In a survey of \(100\) students, \(60\) take mathematics, \(45\) take physics and \(20\) take both. Those taking at least one:
\[|M \cup P| = 60 + 45 - 20 = 85\]so \(100 - 85 = 15\) take neither. With three sets, say \(|A| = 30\), \(|B| = 25\), \(|C| = 20\), \(|A \cap B| = 10\), \(|A \cap C| = 8\), \(|B \cap C| = 6\), \(|A \cap B \cap C| = 3\):
\[|A \cup B \cup C| = 30 + 25 + 20 - 10 - 8 - 6 + 3 = 54.\]Filling the Venn diagram for the same data, from the inside out: the triple region holds \(3\). The region in \(A\) and \(B\) only holds \(10 - 3 = 7\); in \(A\) and \(C\) only, \(8 - 3 = 5\); in \(B\) and \(C\) only, \(6 - 3 = 3\). Then \(A\) only is \(30 - 7 - 5 - 3 = 15\), \(B\) only is \(25 - 7 - 3 - 3 = 12\), \(C\) only is \(20 - 5 - 3 - 3 = 9\). The seven regions add to \(15 + 12 + 9 + 7 + 5 + 3 + 3 = 54\), matching the formula, and questions such as “exactly one set” (\(15 + 12 + 9 = 36\)) or “exactly two” (\(7 + 5 + 3 = 15\)) are read straight off the diagram.
Watch out. \(\emptyset\) and \(\{\emptyset\}\) are different sets, with \(0\) and \(1\) elements, and \(a \in A\) is not the same statement as \(\{a\} \subseteq A\). Students also write \(|\mathcal{P}(A)| = 2|A|\); it is \(2^{|A|}\), so a set with \(10\) elements has \(1{,}024\) subsets, not \(20\). And in inclusion–exclusion the triple intersection is added back, not subtracted a third time.
Practice: problems 7, 8, 9, 10, 11, 12, 48, 70 (the practice groups are the last entries in the contents).
Functions and relations
Unit I: Logic and sets · Topic 3 of 13
Key idea
A function \(f : A \to B\) assigns to every element of the domain \(A\) exactly one element of the codomain \(B\); the set of values actually hit is the range. The questions that matter are whether \(f\) is one-to-one, onto, or both, because a bijection is exactly a function that can be inverted. A relation from \(A\) to \(B\) is any subset of \(A \times B\), so every function is a relation but most relations are not functions. Relations on a single set are classified by four properties, and the two most important combinations, equivalence relations and partial orders, organize everything from congruence modulo \(m\) to the subset ordering on a power set.
Injective (one-to-one): \(f(a_1) = f(a_2)\) implies \(a_1 = a_2\); different inputs give different outputs. Surjective (onto): every \(b \in B\) equals \(f(a)\) for some \(a\); the range is the whole codomain. Bijective: both, and then \(f^{-1} : B \to A\) exists with \(f^{-1}(f(a)) = a\).
Composition. \((g \circ f)(x) = g(f(x))\): apply \(f\) first. If \(f\) and \(g\) are injective so is \(g \circ f\); the same for surjective. And \((g \circ f)^{-1} = f^{-1} \circ g^{-1}\): undo the last step first. Check with \(f(x) = 2x + 1\), \(g(x) = x - 3\) on \(\mathbb{R}\): \((g \circ f)(x) = 2x - 2\) has inverse \(\tfrac{y + 2}{2}\), and \(f^{-1}(g^{-1}(y)) = f^{-1}(y + 3) = \tfrac{(y + 3) - 1}{2} = \tfrac{y + 2}{2}\), the same.
Counting functions from an \(m\)-element set to an \(n\)-element set:
\[\text{all: } n^m\] \[\text{injective: } n(n-1)\cdots(n-m+1)\] \[\text{bijective } (m = n): n!\]No injection exists when \(m \gt n\) (pigeonhole), and no surjection when \(m \lt n\).
Floor \(\lfloor x \rfloor\) is the greatest integer \(\le x\); ceiling \(\lceil x \rceil\) the least integer \(\ge x\). So \(\lfloor -2.5 \rfloor = -3\) and \(\lceil 2.1 \rceil = 3\). In symbols, \(\lfloor x \rfloor = n \iff n \le x \lt n + 1\) and \(\lceil x \rceil = n \iff n - 1 \lt x \le n\), which is how an equation such as \(\lceil x/3 \rceil = 4\) is solved: \(3 \lt x/3 \le 4\), i.e. \(9 \lt x \le 12\).
- Reflexive \((a, a) \in R\) for every \(a\). Symmetric \((a, b) \in R\) implies \((b, a) \in R\).
- Antisymmetric \((a, b)\) and \((b, a)\) both in \(R\) force \(a = b\). Transitive \((a, b), (b, c) \in R\) imply \((a, c) \in R\).
- Equivalence relation reflexive, symmetric and transitive. It splits the set into disjoint equivalence classes \([a] = \{x : x\,R\,a\}\); the classes form a partition, and every partition comes from exactly one equivalence relation.
- Partial order reflexive, antisymmetric and transitive, e.g. \(\le\) on \(\mathbb{Z}\), \(\subseteq\) on \(\mathcal{P}(S)\), divisibility on \(\mathbb{Z}^+\). Drawn as a Hasse diagram (no loops, no edges implied by transitivity, larger elements higher). A total order has every pair comparable.
- Counting relations on an \(n\)-element set: \(2^{n^2}\) in all, \(2^{n^2 - n}\) reflexive, \(2^{n(n+1)/2}\) symmetric. Reason: a relation is a subset of the \(n^2\) ordered pairs, each in or out; reflexive forces the \(n\) diagonal pairs in, leaving \(n^2 - n\) free choices; symmetric is decided by the \(n(n+1)/2\) pairs on or above the diagonal, since each pair below is a copy of one above.
- Representations a zero–one matrix (reflexive: ones on the diagonal; symmetric: the matrix equals its transpose) or a directed graph. E.g. \(R = \{(1, 1), (1, 2), (2, 1)\}\) on \(\{1, 2, 3\}\) has matrix rows \((1, 1, 0)\), \((1, 0, 0)\), \((0, 0, 0)\): symmetric (equal to its transpose) but not reflexive (zeros in positions \((2, 2)\) and \((3, 3)\)), and not transitive, since \((2, 1), (1, 2) \in R\) but \((2, 2) \notin R\).
Congruence modulo \(m\) is the model equivalence relation; its classes are \([0], [1], \dots, [m-1]\).
How to work it
- One-to-one: set \(f(a_1) = f(a_2)\) and solve; if the only way out is \(a_1 = a_2\), it is injective. One pair of inputs with equal outputs is a counterexample.
- Onto: take an arbitrary \(b\) in the codomain and try to solve \(f(a) = b\) for \(a\) inside the domain. A value you cannot hit shows it is not onto.
- Bijective: both tests passed; find \(f^{-1}\) by solving \(y = f(x)\) for \(x\).
- For a relation, check each of the four properties separately; a single failing pair settles a property as false, a general argument is needed to show it true.
- Reflexive, symmetric, transitive: list the equivalence classes. Reflexive, antisymmetric, transitive: draw the Hasse diagram.
Let \(f : \mathbb{Z} \to \mathbb{Z}\), \(f(n) = 2n + 1\). If \(2a + 1 = 2b + 1\) then \(a = b\), so \(f\) is injective. But \(f(n)\) is always odd, so \(0\) is never a value: \(f\) is not surjective, hence not a bijection. The same formula \(g : \mathbb{R} \to \mathbb{R}\), \(g(x) = 2x + 1\), is a bijection with \(g^{-1}(y) = (y - 1)/2\): changing the domain and codomain changes the answer.
Define \(R\) on \(\mathbb{Z}\) by \(a\,R\,b\) iff \(3 \mid (a - b)\). Reflexive: \(3 \mid 0\). Symmetric: if \(a - b = 3k\) then \(b - a = 3(-k)\). Transitive: \(a - b = 3k\) and \(b - c = 3l\) give
\[a - c = (a - b) + (b - c) = 3(k + l).\]So \(R\) is an equivalence relation with three classes, \([0] = \{\dots, -3, 0, 3, 6, \dots\}\), \([1]\) and \([2]\), which partition \(\mathbb{Z}\).
Counting: there are \(4^3 = 64\) functions from a \(3\)-element set to a \(4\)-element set, of which \(4 \cdot 3 \cdot 2 = 24\) are injective and none are surjective.
Hasse diagram. Divisibility on \(\{1, 2, 3, 4, 6, 12\}\) is a partial order (reflexive: \(a \mid a\); antisymmetric: \(a \mid b\) and \(b \mid a\) force \(a = b\) for positive integers; transitive: \(a \mid b \mid c\) gives \(a \mid c\)). Draw \(1\) at the bottom; \(2\) and \(3\) above it; \(4\) and \(6\) above \(2\), with \(6\) also above \(3\); \(12\) at the top above \(4\) and \(6\). The edges are \(1\)–\(2\), \(1\)–\(3\), \(2\)–\(4\), \(2\)–\(6\), \(3\)–\(6\), \(4\)–\(12\), \(6\)–\(12\). There is no edge \(1\)–\(12\) because it follows by transitivity, and \(4\) and \(6\) are incomparable (neither divides the other), which is why the order is partial and not total. Least element \(1\), greatest element \(12\).
Watch out. “Antisymmetric” is not the opposite of “symmetric”: the equality relation is both, and \(\{(1, 2), (2, 1), (1, 3)\}\) is neither. Onto depends on the stated codomain, so \(f(x) = x^2\) is onto \([0, \infty)\) but not onto \(\mathbb{R}\); and a relation fails to be reflexive as soon as one element \(a\) has \((a, a) \notin R\), however many others have it.
Practice: problems 11, 13, 14, 15, 16, 17, 18, 19, 20, 66, 67, 68, 69, 70, 71 (the practice groups are the last entries in the contents).
Direct, contrapositive and contradiction proofs
Unit II: Proofs and number theory · Topic 4 of 13
Key idea
A proof is a chain of statements, each justified by a definition, a previous result or a rule of inference, that ends at the claim. Most claims in a first course have the shape \(p \to q\), and there are three standard ways to attack one. A direct proof assumes \(p\) and works forward to \(q\). A proof by contrapositive assumes \(\lnot q\) and derives \(\lnot p\), which is legitimate because \(\lnot q \to \lnot p\) is equivalent to \(p \to q\). A proof by contradiction assumes \(p\) and \(\lnot q\) together and derives something impossible. Choosing the method is half the work: look at which assumption hands you something concrete to compute with.
Direct. Assume \(p\). Unpack definitions, compute, reach \(q\).
Contrapositive. Assume \(\lnot q\). Reach \(\lnot p\). Use it when \(\lnot q\) is more concrete than \(p\) (“\(n\) is odd” is easier to use than “\(n^2\) is even”).
Contradiction. Assume \(p\) and \(\lnot q\). Derive \(r \land \lnot r\) for some statement \(r\). Use it when the claim is a negative (“there is no …”, “… is irrational”).
Definitions you will unpack (with \(k, c, p, q\) integers):
\[n \text{ even} \iff n = 2k\] \[n \text{ odd} \iff n = 2k + 1\] \[a \mid b \iff b = ac\] \[x \text{ rational} \iff x = \tfrac{p}{q},\ q \ne 0.\]For a rational number you may take \(p/q\) in lowest terms, which is often where the contradiction comes from.
A biconditional \(p \leftrightarrow q\) needs two proofs: \(p \to q\) and \(q \to p\). A chain \(p_1 \leftrightarrow p_2 \leftrightarrow \cdots \leftrightarrow p_k\) proves all the statements equivalent at once.
- Proof by cases split the hypothesis into exhaustive cases (\(n\) even or odd; \(x \ge 0\) or \(x \lt 0\)) and prove each. Every case must be covered.
- Existence constructive: exhibit the object. Nonconstructive: show one must exist, e.g. by pigeonhole or by contradiction.
- Uniqueness show existence, then suppose two objects satisfy the property and prove they are equal. E.g. the solution of \(3x + 2 = 11\) is unique: if \(3a + 2 = 11\) and \(3b + 2 = 11\), subtracting gives \(3(a - b) = 0\), so \(a = b\); existence is \(x = 3\).
- Disproving \(\forall x\,P(x)\) one counterexample suffices. Disproving \(\exists x\,P(x)\) requires a proof that every \(x\) fails.
- Vacuous and trivial \(p \to q\) is proved by showing \(p\) is always false (vacuous) or \(q\) is always true (trivial). E.g. “if \(n\) is a prime with \(n^2 \lt 2\), then \(n\) is even” is vacuously true because no such prime exists, and “if \(n\) is odd then \(n^2 \ge 0\)” is trivially true.
- Classics \(\sqrt{2}\) is irrational (contradiction via lowest terms); there are infinitely many primes (contradiction: look at \(p_1p_2\cdots p_n + 1\)); if \(n^2\) is even then \(n\) is even (contrapositive); the sum of two rationals is rational (direct).
“Without loss of generality” is allowed only when the cases really are symmetric.
How to work it
- Write the claim as \(p \to q\) and identify \(p\) and \(q\) precisely, including the domain (integers? reals?).
- Pick the template: direct if \(p\) hands you an equation; contrapositive if \(\lnot q\) does; contradiction for negative claims. Announce it in the first sentence.
- State the assumption in its unpacked form (“so \(n = 2k + 1\) for some integer \(k\)”), introducing a name for every quantity.
- Compute toward the goal, and when you arrive, write the goal in its own definitional form (“\(= 2(\dots) + 1\), which is odd”).
- Close with the conclusion in the words of the original claim; for a contradiction, name the two statements that clash.
Claim. If \(n^2\) is even, then \(n\) is even. By contrapositive: suppose \(n\) is odd, so \(n = 2k + 1\). Then
\[n^2 = 4k^2 + 4k + 1 = 2(2k^2 + 2k) + 1\]which is odd. So \(n\) odd forces \(n^2\) odd, which is the contrapositive of the claim. (A direct proof would start from \(n^2 = 2m\) and have nowhere to go.)
Claim. \(\sqrt{2}\) is irrational. By contradiction: suppose \(\sqrt{2} = p/q\) in lowest terms. Squaring,
\[p^2 = 2q^2\]so \(p^2\) is even, hence \(p\) is even by the first claim, say \(p = 2r\). Then \(4r^2 = 2q^2\) gives \(q^2 = 2r^2\), so \(q\) is even too. Now \(p\) and \(q\) share the factor \(2\), contradicting lowest terms. Hence no such fraction exists.
Counterexample. “Every integer of the form \(n^2 + n + 41\) is prime” is true for \(n = 0, 1, \dots, 39\) and fails at \(n = 40\), since \(40^2 + 40 + 41 = 1681 = 41^2\). One instance is enough to disprove a universal statement.
Claim (by cases). \(n^2 + n\) is even for every integer \(n\). Case 1, \(n = 2k\): \(n^2 + n = 4k^2 + 2k = 2(2k^2 + k)\). Case 2, \(n = 2k + 1\): \(n^2 + n = 4k^2 + 4k + 1 + 2k + 1 = 2(2k^2 + 3k + 1)\). Every integer falls in one of the two cases, so the claim holds. The cases must be exhaustive, and each must end at the goal in its definitional form. (Shorter: \(n^2 + n = n(n + 1)\), and one of two consecutive integers is even.)
Watch out. Proving the converse by mistake is the most common structural error: assuming \(q\) and reaching \(p\) proves \(q \to p\), not \(p \to q\). The second is circular reasoning, using the claim (or a rephrasing of it) somewhere in the middle. And a list of examples, however long, never proves a “for all” statement, although a single example disproves one.
Practice: problems 6, 21, 22, 26, 39, 40 (the practice groups are the last entries in the contents).
Mathematical induction
Unit II: Proofs and number theory · Topic 5 of 13
Key idea
Mathematical induction proves a statement \(P(n)\) for every integer \(n \ge b\) in two moves. The basis step checks \(P(b)\) directly. The inductive step shows that for every \(k \ge b\), if \(P(k)\) holds then \(P(k + 1)\) holds; the assumption \(P(k)\) is the inductive hypothesis. Together they knock down the whole row of dominoes: \(P(b)\), then \(P(b + 1)\), then \(P(b + 2)\), and so on. Strong induction lets you assume \(P(b), P(b + 1), \dots, P(k)\) all at once, which is what recurrences and arguments that reach back several cases need. Induction is the standard tool for summation formulas, inequalities, divisibility statements and closed forms of recursively defined sequences.
Induction. If \(P(b)\) is true and \(P(k) \to P(k + 1)\) for every \(k \ge b\), then \(P(n)\) is true for all \(n \ge b\).
Strong induction. If \(P(b)\) is true and \([P(b) \land \cdots \land P(k)] \to P(k + 1)\) for every \(k \ge b\), then \(P(n)\) holds for all \(n \ge b\). Equivalent to ordinary induction and to the well-ordering principle (every nonempty set of nonnegative integers has a least element).
Sums proved by induction.
\[\sum_{i=1}^{n} i = \frac{n(n+1)}{2}\] \[\sum_{i=1}^{n} i^2 = \frac{n(n+1)(2n+1)}{6}\] \[\sum_{i=1}^{n} i^3 = \left(\frac{n(n+1)}{2}\right)^2\] \[\sum_{i=0}^{n} r^i = \frac{r^{n+1} - 1}{r - 1}\ \ (r \ne 1)\] \[\sum_{i=1}^{n} (2i - 1) = n^2.\]The inductive step for a sum always has the shape \(S_{k+1} = S_k + (\text{next term})\): substitute the hypothesis for \(S_k\), add the term, simplify to the formula at \(k + 1\). For the first formula: \(\tfrac{k(k+1)}{2} + (k + 1) = (k + 1)\left(\tfrac{k}{2} + 1\right) = \tfrac{(k+1)(k+2)}{2}\), which is the right-hand side with \(n = k + 1\).
- Divisibility e.g. \(3 \mid n^3 - n\): write \((k+1)^3 - (k+1) = (k^3 - k) + 3(k^2 + k)\), a multiple of \(3\) by hypothesis plus a visible multiple of \(3\).
- Inequalities e.g. \(2^n \gt n^2\) for \(n \ge 5\), \(n! \gt 2^n\) for \(n \ge 4\): the basis is the first \(n\) where the claim is true, and the step usually needs a side inequality such as \(2k^2 \ge (k+1)^2\) for \(k \ge 3\). For \(n! \gt 2^n\): basis \(4! = 24 \gt 16\); step \((k + 1)! = (k + 1)\,k! \gt (k + 1)2^k \ge 2\cdot 2^k = 2^{k+1}\), using the hypothesis once and then \(k + 1 \ge 2\).
- Recurrences if \(a_n = 2a_{n-1} + 1\) with \(a_0 = 0\), then \(a_n = 2^n - 1\): assume it for \(k\) and compute \(a_{k+1} = 2(2^k - 1) + 1 = 2^{k+1} - 1\).
- Strong induction every \(n \ge 12\) is a sum of \(4\)s and \(5\)s: basis \(12, 13, 14, 15\); for \(k + 1 \ge 16\) use the representation of \(k + 1 - 4\) and add one \(4\).
- Structural facts a set with \(n\) elements has \(2^n\) subsets; a tree with \(n\) vertices has \(n - 1\) edges; \(n\) lines in general position divide the plane into \(\tfrac{n(n+1)}{2} + 1\) regions (the \((k + 1)\)-st line crosses the \(k\) others at \(k\) points, so it passes through \(k + 1\) regions and splits each: the step adds \(k + 1\)).
When the step for \(k + 1\) reaches back more than one case (as \(a_{k+1} = a_k + a_{k-1}\) does), use strong induction and check enough basis cases to cover every reference.
How to work it
- State \(P(n)\) explicitly as a statement about \(n\), and say where it starts (\(n \ge b\)).
- Basis: verify \(P(b)\) by direct computation, both sides separately.
- Inductive step: write “assume \(P(k)\) for some \(k \ge b\),” and copy the hypothesis out in full.
- Write down what \(P(k + 1)\) says. Start from its left side, use the hypothesis once (mark where), and simplify to its right side.
- Conclude: “by induction, \(P(n)\) holds for all \(n \ge b\).” If you needed \(P(k - 1)\) as well, go back and change to strong induction with extra basis cases.
Claim. \(1 + 3 + 5 + \cdots + (2n - 1) = n^2\) for \(n \ge 1\). Basis: \(n = 1\) gives \(1 = 1^2\). Step: assume the sum of the first \(k\) odd numbers is \(k^2\). Then
\[1 + 3 + \cdots + (2k - 1) + (2k + 1) = k^2 + (2k + 1)\] \[= (k + 1)^2\]which is the claim at \(k + 1\). Done.
Claim. \(2^n \gt n^2\) for all \(n \ge 5\). Basis: \(2^5 = 32 \gt 25\). (The claim is false at \(n = 4\), where \(16 = 16\), so \(5\) is the right start.) Step: assume \(2^k \gt k^2\) with \(k \ge 5\). Then
\[2^{k+1} = 2 \cdot 2^k \gt 2k^2 = k^2 + k^2 \ge k^2 + 2k + 1 = (k + 1)^2\]where \(k^2 \ge 2k + 1\) holds because \(k \ge 3\). So \(2^{k+1} \gt (k + 1)^2\), and by induction the inequality holds for every \(n \ge 5\).
Claim (strong induction). Every \(n \ge 12\) is a sum of \(4\)s and \(5\)s. Basis, four cases because the step will reach back four: \(12 = 4 + 4 + 4\), \(13 = 4 + 4 + 5\), \(14 = 4 + 5 + 5\), \(15 = 5 + 5 + 5\). Step: let \(k \ge 15\) and assume every \(n\) with \(12 \le n \le k\) is such a sum. Since \(k + 1 - 4 = k - 3 \ge 12\), the hypothesis applies to \(k - 3\); add one more \(4\) to its representation to get \(k + 1\). The step needs \(k - 3 \ge 12\), which is exactly why the basis must run up to \(15\) and not stop at \(12\).
Watch out. Skipping or faking the basis step is the classic failure: the inductive step of “all horses are the same colour” is fine for \(k \ge 2\), and the whole argument collapses only because \(P(1) \to P(2)\) fails. The other failure is never using the hypothesis, which means you have written a direct proof of \(P(k + 1)\) that is usually wrong. Start the basis at the \(n\) where the claim actually begins, not at \(n = 1\) by reflex.
Practice: problems 22, 23, 24, 25, 39 (the practice groups are the last entries in the contents).
Divisibility, gcd and modular arithmetic
Unit II: Proofs and number theory · Topic 6 of 13
Key idea
Number theory in a discrete course is the arithmetic of integers: divisibility \(a \mid b\), the division algorithm that writes \(a = dq + r\) with \(0 \le r \lt d\), the greatest common divisor and the Euclidean algorithm that computes it, primes and unique factorization, and congruences \(a \equiv b \pmod m\). Modular arithmetic turns the infinite set \(\mathbb{Z}\) into the finite set \(\{0, 1, \dots, m - 1\}\) where addition and multiplication still behave, and that is the setting for hashing, check digits and public-key cryptography. The computational core is the extended Euclidean algorithm, which produces \(\gcd(a, b)\) as a combination \(sa + tb\) and, from it, inverses and solutions of linear congruences.
Divides. \(a \mid b\) means \(b = ac\) for some integer \(c\). If \(a \mid b\) and \(a \mid c\) then \(a \mid (mb + nc)\) for all integers \(m, n\).
Division algorithm. For \(d \gt 0\) there are unique \(q, r\) with \(a = dq + r\) and \(0 \le r \lt d\); write \(r = a \bmod d\). The remainder is never negative: \(-7 = 3(-3) + 2\), so \(-7 \bmod 3 = 2\).
gcd and lcm. \(\gcd(a, b)\) is the largest positive common divisor; \(a, b\) are relatively prime when it is \(1\). From prime factorizations, take the smaller exponent of each prime for the gcd and the larger for the lcm: \(12 = 2^2\cdot 3\) and \(18 = 2\cdot 3^2\) give \(\gcd = 2\cdot 3 = 6\) and \(\operatorname{lcm} = 2^2\cdot 3^2 = 36\). Always
\[\gcd(a, b) \cdot \operatorname{lcm}(a, b) = ab\] \[\gcd(a, b) = \gcd(b,\ a \bmod b)\] \[\gcd(a, 0) = a.\]The second identity is the Euclidean algorithm: divide, replace the pair by (divisor, remainder), stop at remainder \(0\).
Bézout. There are integers \(s, t\) with \(sa + tb = \gcd(a, b)\); back-substituting through the Euclidean steps finds them (the extended algorithm).
Fundamental theorem of arithmetic: every \(n \ge 2\) is a product of primes in exactly one way up to order. To test \(n\) for primality, trial divide by the primes up to \(\sqrt{n}\): for \(n = 97\), \(\sqrt{97} \lt 10\), and none of \(2, 3, 5, 7\) divides \(97\), so \(97\) is prime. The bound works because a composite \(n = ab\) with \(a \le b\) has \(a \le \sqrt{n}\).
- Definition \(a \equiv b \pmod m\) iff \(m \mid (a - b)\) iff \(a \bmod m = b \bmod m\). It is an equivalence relation with classes \([0], \dots, [m - 1]\).
- Arithmetic if \(a \equiv b\) and \(c \equiv d \pmod m\) then \(a + c \equiv b + d\) and \(ac \equiv bd\). So reduce as you go: \((ab) \bmod m = ((a \bmod m)(b \bmod m)) \bmod m\).
- Inverses \(a\) has an inverse \(\overline{a}\) with \(a\overline{a} \equiv 1 \pmod m\) iff \(\gcd(a, m) = 1\); Bézout gives it (\(sa + tm = 1\) means \(\overline{a} = s\)).
- Linear congruences \(ax \equiv b \pmod m\) with \(d = \gcd(a, m)\): no solution if \(d \nmid b\); otherwise exactly \(d\) solutions mod \(m\). When \(d = 1\), \(x \equiv \overline{a}\,b\).
- Fermat’s little theorem for a prime \(p\) and \(p \nmid a\), \(a^{p-1} \equiv 1 \pmod p\). Reduce big exponents mod \(p - 1\). It also gives inverses: \(a^{p-2}\) is the inverse of \(a\) modulo \(p\), e.g. \(3^5 = 243 \equiv 5 \pmod 7\) and indeed \(3 \cdot 5 = 15 \equiv 1\).
- Chinese remainder theorem if \(m_1, \dots, m_k\) are pairwise relatively prime, the system \(x \equiv a_i \pmod{m_i}\) has a unique solution mod \(m_1 \cdots m_k\). To build it, let \(M = m_1\cdots m_k\), \(M_i = M/m_i\), and let \(y_i\) be the inverse of \(M_i\) modulo \(m_i\); then \(x = \sum_i a_iM_iy_i\), because the \(i\)-th term is \(a_i\) modulo \(m_i\) and every other term is a multiple of \(m_i\).
- Fast powers compute \(a^n \bmod m\) by repeated squaring, reducing after every multiplication.
Bases: to write \(45\) in binary, divide by \(2\) repeatedly and read the remainders from last to first: \(45 = 2\cdot 22 + 1\), \(22 = 2\cdot 11 + 0\), \(11 = 2\cdot 5 + 1\), \(5 = 2\cdot 2 + 1\), \(2 = 2\cdot 1 + 0\), \(1 = 2\cdot 0 + 1\), so \(45 = 101101_2\) (check: \(32 + 8 + 4 + 1 = 45\)). The other direction is positional: \(2\mathrm{F}3_{16} = 2\cdot 256 + 15\cdot 16 + 3 = 755\). Each hexadecimal digit stands for four binary digits.
How to work it
- Run the Euclidean algorithm, writing every line as \(\text{larger} = q \cdot \text{smaller} + r\); the last nonzero remainder is the gcd.
- Starting from the line that produced the gcd, solve each line for its remainder and substitute upward until the gcd is written as \(sa + tb\).
- Check \(sa + tb\) numerically. The coefficient of \(a\), reduced mod \(b\), is the inverse of \(a\) modulo \(b\) (when the gcd is \(1\)).
- To solve \(ax \equiv b \pmod m\): if \(\gcd(a, m) = 1\), multiply both sides by \(\overline{a}\) and reduce. If \(\gcd(a, m) = d \gt 1\), check \(d \mid b\), divide the whole congruence (including \(m\)) by \(d\), solve, then list the \(d\) solutions mod \(m\).
- Substitute the answer back into the original congruence.
\(\gcd(252, 198)\):
\[252 = 1 \cdot 198 + 54\] \[198 = 3 \cdot 54 + 36\] \[54 = 1 \cdot 36 + 18\] \[36 = 2 \cdot 18 + 0\]so the gcd is \(18\) and \(\operatorname{lcm}(252, 198) = 252 \cdot 198 / 18 = 2772\). Back-substitute:
\[18 = 54 - 36 = 54 - (198 - 3 \cdot 54) = 4 \cdot 54 - 198\] \[= 4(252 - 198) - 198 = 4 \cdot 252 - 5 \cdot 198.\]Check: \(1008 - 990 = 18\).
Solve \(7x \equiv 3 \pmod{26}\). Euclid on \((26, 7)\): \(26 = 3 \cdot 7 + 5\), \(7 = 1 \cdot 5 + 2\), \(5 = 2 \cdot 2 + 1\). Back:
\[1 = 5 - 2 \cdot 2 = 5 - 2(7 - 5) = 3 \cdot 5 - 2 \cdot 7\] \[= 3(26 - 3 \cdot 7) - 2 \cdot 7 = 3 \cdot 26 - 11 \cdot 7.\]So \(\overline{7} \equiv -11 \equiv 15 \pmod{26}\) (check: \(7 \cdot 15 = 105 = 4 \cdot 26 + 1\)), and \(x \equiv 15 \cdot 3 = 45 \equiv 19 \pmod{26}\). Check: \(7 \cdot 19 = 133 = 5 \cdot 26 + 3\).
Fermat: \(3^{100} \bmod 7\). Since \(3^6 \equiv 1 \pmod 7\) and \(100 = 6 \cdot 16 + 4\), \(3^{100} \equiv 3^4 = 81 \equiv 4 \pmod 7\).
Linear congruence with \(d \gt 1\): \(4x \equiv 6 \pmod{10}\). Here \(d = \gcd(4, 10) = 2\) and \(2 \mid 6\), so divide everything, modulus included, by \(2\): \(2x \equiv 3 \pmod 5\). The inverse of \(2\) mod \(5\) is \(3\) (\(2 \cdot 3 = 6 \equiv 1\)), so \(x \equiv 3 \cdot 3 = 9 \equiv 4 \pmod 5\), and the \(d = 2\) solutions mod \(10\) are \(x = 4\) and \(x = 9\). Check: \(16 \equiv 6\) and \(36 \equiv 6 \pmod{10}\).
Chinese remainder theorem: \(x \equiv 2 \pmod 3\), \(x \equiv 3 \pmod 5\). With \(M = 15\), \(M_1 = 15/3 = 5\) and \(M_2 = 15/5 = 3\); the inverse of \(5\) mod \(3\) is \(2\) (\(5 \cdot 2 = 10 \equiv 1\)) and the inverse of \(3\) mod \(5\) is \(2\) (\(3 \cdot 2 = 6 \equiv 1\)). Then \(x = 2 \cdot 5 \cdot 2 + 3 \cdot 3 \cdot 2 = 20 + 18 = 38 \equiv 8 \pmod{15}\). Check: \(8 = 2 \cdot 3 + 2\) and \(8 = 1 \cdot 5 + 3\).
Repeated squaring: \(3^{13} \bmod 7\). Since \(13 = 8 + 4 + 1\), square and reduce: \(3^2 = 9 \equiv 2\), \(3^4 \equiv 2^2 = 4\), \(3^8 \equiv 4^2 = 16 \equiv 2\). Then \(3^{13} = 3^8 \cdot 3^4 \cdot 3 \equiv 2 \cdot 4 \cdot 3 = 24 \equiv 3 \pmod 7\). Four multiplications instead of twelve, and no intermediate number ever exceeds \(6^2 = 36\).
Watch out. You cannot divide both sides of a congruence by a number unless it is relatively prime to the modulus: \(6x \equiv 4 \pmod 8\) has two solutions, \(x = 2\) and \(x = 6\), not one, and \(2x \equiv 1 \pmod 4\) has none. Also \(a \bmod m\) is always in \(\{0, \dots, m - 1\}\), so \(-7 \bmod 3\) is \(2\), not \(-1\); a calculator that reports \(-1\) is using a different convention.
Practice: problems 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 40 (the practice groups are the last entries in the contents).
Permutations, combinations and the pigeonhole principle
Unit III: Counting and probability · Topic 7 of 13
Key idea
Counting problems ask how many objects of a certain kind exist, and nearly all of them are built from two rules. The product rule: a procedure done in stages with \(n_1, n_2, \dots\) choices at each stage can be done in \(n_1 n_2 \cdots\) ways. The sum rule: if the objects split into disjoint types, add the counts. Permutations count ordered selections and combinations unordered ones, and the whole skill is deciding which one a question is asking for, whether repetition is allowed, and whether a complement (“at least one”) or a subtraction of overcounts is needed. The pigeonhole principle is the opposite kind of statement: it guarantees that some box is crowded without counting anything exactly.
Permutations (order matters, no repetition): the number of ordered selections of \(r\) objects from \(n\) is
\[P(n, r) = \frac{n!}{(n - r)!} = n(n-1)\cdots(n-r+1)\] \[P(n, n) = n!\]Gold, silver and bronze among \(7\) runners: \(P(7, 3) = 7 \cdot 6 \cdot 5 = 210\). A team of \(3\) of the \(7\) with no ranking: \(C(7, 3) = 210 / 3! = 35\), because each team was counted once for each of its \(3! = 6\) orderings.
Combinations (order does not matter, no repetition):
\[C(n, r) = \binom{n}{r} = \frac{n!}{r!\,(n-r)!} = \frac{P(n, r)}{r!}.\]With repetition. Ordered strings of length \(r\) over \(n\) symbols: \(n^r\). Unordered selections of \(r\) objects from \(n\) types (stars and bars): \(\binom{n + r - 1}{r}\).
Why stars and bars: a selection of \(r\) donuts from \(n\) varieties is a row of \(r\) stars split by \(n - 1\) bars into \(n\) groups, e.g. \(\star\star \mid\ \mid \star\) means two of variety 1, none of variety 2, one of variety 3. Choosing which \(r\) of the \(n + r - 1\) symbols are stars fixes the selection, hence \(\binom{n + r - 1}{r}\). The formula applies only when the objects of one type are indistinguishable and order is irrelevant.
Arrangements of a multiset. \(n\) objects with \(n_1\) alike of type 1, \(n_2\) of type 2, and so on:
\[\frac{n!}{n_1!\,n_2!\cdots n_k!}.\]Circular arrangements of \(n\) distinct people: \((n - 1)!\). Objects that must stay together: tie them into one block, arrange the blocks, then arrange inside the block. E.g. \(5\) books on a shelf with two particular books adjacent: \(4!\) orders of the four objects (the pair counts as one) times \(2!\) orders inside the pair, \(24 \cdot 2 = 48\).
- Product rule stages multiply. Sum rule disjoint cases add. Subtraction \(|A \cup B| = |A| + |B| - |A \cap B|\) when cases overlap.
- Complement “at least one” is the total minus “none”: bit strings of length \(8\) with at least one \(1\): \(2^8 - 1 = 255\).
- Derangements a permutation with no object in its original place. By inclusion–exclusion on the events “object \(i\) is fixed,” \(D_n = n!\left(1 - \tfrac{1}{1!} + \tfrac{1}{2!} - \cdots + \tfrac{(-1)^n}{n!}\right)\), so \(D_1, D_2, D_3, D_4, D_5 = 0, 1, 2, 9, 44\); e.g. \(D_4 = 24\left(1 - 1 + \tfrac12 - \tfrac16 + \tfrac1{24}\right) = 24 \cdot \tfrac{9}{24} = 9\). The fraction \(D_n/n!\) tends to \(1/e \approx 0.368\): if \(n\) hats are returned at random, the chance that nobody gets their own is about \(37\%\) for every \(n \ge 4\).
- Division rule if every object is counted \(d\) times, divide by \(d\) (that is where the \(r!\) in \(C(n, r)\) and the \((n-1)!\) for circles come from). E.g. \(4\) people at a round table: \(4!\) lineups, but each seating is counted \(4\) times, once per rotation, so there are \(4!/4 = 6\) seatings.
- Pigeonhole \(N\) objects in \(k\) boxes put at least \(\lceil N/k \rceil\) in some box. Among \(13\) people two share a birth month; among \(25\) people, at least \(\lceil 25/12 \rceil = 3\) do.
- Pigeonhole in disguise among any \(n + 1\) integers from \(\{1, \dots, 2n\}\) two are consecutive (boxes \(\{1, 2\}, \{3, 4\}, \dots\)), and one of them divides another (boxes by largest odd divisor).
- Choosing the boxes the hard part of a pigeonhole problem is naming the \(k\) boxes so that two objects in one box are exactly what you want. E.g. among any \(5\) points in a unit square, two are within distance \(\tfrac{\sqrt2}{2}\): cut the square into \(4\) quarter squares (the boxes); two of the \(5\) points share one, and a quarter square has diagonal \(\tfrac{\sqrt2}{2}\).
Keywords: “arrange, order, sequence, rank” signal permutations; “choose, committee, subset, hand” signal combinations.
How to work it
- Ask: does order matter? Is repetition allowed? Are the objects distinguishable? Those three answers pick the formula.
- Break the construction into stages (product rule) or into disjoint cases (sum rule), never both at once in a single line.
- If the question says “at least” or “not”, count the complement and subtract from the total.
- Check for overcounting: if two different sequences of choices produce the same object, divide by the number of repeats or recount by cases.
- Sanity check with a small instance you can list by hand, or compare with a second method.
A committee of \(5\) is chosen from \(8\) women and \(6\) men with at least \(3\) women. Split into disjoint cases by the number of women:
\[\binom{8}{3}\binom{6}{2} + \binom{8}{4}\binom{6}{1} + \binom{8}{5}\binom{6}{0} = 56 \cdot 15 + 70 \cdot 6 + 56\] \[= 840 + 420 + 56 = 1316.\]The tempting shortcut “choose \(3\) women, then any \(2\) of the remaining \(11\) people” gives \(\binom{8}{3}\binom{11}{2} = 3080\), an overcount, because a committee with \(4\) women is produced by several different choices of the “first three.”
A dozen donuts from \(4\) varieties (unordered, repetition allowed):
\[\binom{12 + 4 - 1}{12} = \binom{15}{12} = \binom{15}{3} = 455.\]The letters of MISSISSIPPI (\(1\) M, \(4\) I, \(4\) S, \(2\) P) can be arranged in \(\dfrac{11!}{1!\,4!\,4!\,2!} = 34{,}650\) ways.
Pigeonhole: in any group of \(25\) people some birth month is shared by at least \(\lceil 25/12 \rceil = 3\) people, since \(12\) months holding at most \(2\) each would cover only \(24\).
Watch out. The committee overcount above is the single most common counting error: fixing “the” special members first and filling the rest freely counts a committee once for every way of naming its special members. Split into exact cases instead. The other classic is treating a combination question as a permutation (or the reverse); if the chosen objects will not be lined up, labelled or ranked, divide out the order.
Practice: problems 10, 17, 41, 42, 43, 44, 45, 48, 49, 50, 51, 52, 53, 55, 56, 58, 64, 68, 77, 78, 100 (the practice groups are the last entries in the contents).
Binomial coefficients and the binomial theorem
Unit III: Counting and probability · Topic 8 of 13
Key idea
The numbers \(\binom{n}{k}\) count the \(k\)-element subsets of an \(n\)-element set, and the binomial theorem says they are also the coefficients when \((x + y)^n\) is multiplied out: each term picks \(y\) from \(k\) of the \(n\) factors and \(x\) from the rest. That double role is the point of the topic. Identities such as \(\binom{n}{k} = \binom{n}{n-k}\) or \(\sum_k \binom{n}{k} = 2^n\) can be proved by algebra (substitute into the theorem) or by a combinatorial argument (count the same set two ways). Pascal’s triangle is the identity \(\binom{n}{k} = \binom{n-1}{k-1} + \binom{n-1}{k}\) written out row by row, and it is the fastest way to get small coefficients by hand.
Binomial theorem. For any \(x, y\) and integer \(n \ge 0\),
\[(x + y)^n = \sum_{k=0}^{n} \binom{n}{k} x^{n-k} y^k\] \[= \binom{n}{0}x^n + \binom{n}{1}x^{n-1}y + \cdots + \binom{n}{n}y^n.\]The term with \(y^k\) is \(\binom{n}{k}x^{n-k}y^k\): the exponents add to \(n\), and the lower index of the coefficient matches the power of \(y\).
Pascal’s identity.
\[\binom{n}{k} = \binom{n-1}{k-1} + \binom{n-1}{k}\] \[\binom{n}{0} = \binom{n}{n} = 1.\]Each entry of Pascal’s triangle is the sum of the two above it. Row \(4\) is \(1, 4, 6, 4, 1\), so \((x + y)^4 = x^4 + 4x^3y + 6x^2y^2 + 4xy^3 + y^4\). Adding neighbours gives row \(5\): \(1, 5, 10, 10, 5, 1\), so the coefficient of \(x^2y^3\) in \((x + y)^5\) is \(\binom{5}{3} = 10\).
Combinatorial reading of Pascal: a \(k\)-subset either contains a fixed element (choose \(k - 1\) more from \(n - 1\)) or does not (choose all \(k\) from \(n - 1\)).
- Symmetry \(\binom{n}{k} = \binom{n}{n-k}\).
- Row sums \(\sum_{k=0}^{n}\binom{n}{k} = 2^n\) (set \(x = y = 1\)); \(\sum_{k=0}^{n}(-1)^k\binom{n}{k} = 0\) for \(n \ge 1\) (set \(x = 1\), \(y = -1\)).
- Weighted sum \(\sum_{k} k\binom{n}{k} = n\,2^{n-1}\) (pick a committee and its chair: choose the chair in \(n\) ways, then any subset of the other \(n - 1\) people). Check \(n = 3\): \(0 + 3 + 6 + 3 = 12 = 3 \cdot 2^2\).
- Vandermonde \(\binom{m+n}{r} = \sum_{k=0}^{r}\binom{m}{k}\binom{n}{r-k}\) (choose \(r\) people from \(m\) women and \(n\) men, split by the number \(k\) of women; check \(m = 2\), \(n = 3\), \(r = 2\): \(\binom{5}{2} = 10 = 1\cdot 3 + 2\cdot 3 + 1\cdot 1\)); with \(m = n = r\) it gives \(\binom{2n}{n} = \sum_k \binom{n}{k}^2\).
- Hockey stick \(\sum_{j=r}^{n}\binom{j}{r} = \binom{n+1}{r+1}\), e.g. \(\binom{2}{2} + \binom{3}{2} + \binom{4}{2} + \binom{5}{2} = 1 + 3 + 6 + 10 = \binom{6}{3} = 20\).
- A particular coefficient in \((ax + b)^n\) the coefficient of \(x^k\) is \(\binom{n}{k}a^k b^{n-k}\). For something like \((x^2 + 2/x)^9\), write the general term and solve for the \(k\) that gives the required power of \(x\).
- Multinomial the coefficient of \(x_1^{n_1}\cdots x_k^{n_k}\) in \((x_1 + \cdots + x_k)^n\) is \(\dfrac{n!}{n_1!\cdots n_k!}\), e.g. the coefficient of \(x^2yz\) in \((x + y + z)^4\) is \(\dfrac{4!}{2!\,1!\,1!} = 12\).
How to work it
- Write the general term \(\binom{n}{k}(\text{first})^{n-k}(\text{second})^k\), keeping any constants and signs inside the parentheses.
- Simplify the powers of the variable to a single exponent in terms of \(k\).
- Set that exponent equal to the power you want and solve for \(k\); if \(k\) is not an integer in \(0, \dots, n\), the coefficient is \(0\).
- Substitute \(k\) back and multiply out the numbers, including \((-1)^k\) when the second term is negative.
- Check with a small case or by symmetry (\(\binom{n}{k} = \binom{n}{n-k}\)).
Coefficient of \(x^5y^3\) in \((2x - y)^8\): the term with \(y^3\) is
\[\binom{8}{3}(2x)^5(-y)^3 = 56 \cdot 32 \cdot (-1)\,x^5y^3 = -1792\,x^5y^3.\]Constant term of \(\left(x^2 + \dfrac{2}{x}\right)^9\): the general term is
\[\binom{9}{k}(x^2)^{9-k}\left(\frac{2}{x}\right)^k = \binom{9}{k}2^k x^{18 - 3k}\]and \(18 - 3k = 0\) at \(k = 6\), so the constant term is \(\binom{9}{6}2^6 = 84 \cdot 64 = 5376\).
Identity \(\sum_{k=0}^{n}\binom{n}{k} = 2^n\), two ways. Algebra: put \(x = y = 1\) in the binomial theorem. Counting: both sides count the subsets of an \(n\)-element set, the left side by size, the right side by deciding in or out for each element.
Watch out. With \((x - y)^n\) the sign of the \(y^k\) term is \((-1)^k\), and forgetting it flips every other coefficient. The other slip is matching \(k\) to the wrong factor: in \(\binom{n}{k}x^{n-k}y^k\) the lower index is the exponent of the second term, so the coefficient of \(x^5y^3\) in \((x + y)^8\) is \(\binom{8}{3}\), which happens to equal \(\binom{8}{5}\) by symmetry but will not save you once constants are attached.
Practice: problems 43, 46, 47, 50, 54, 55, 62 (the practice groups are the last entries in the contents).
Discrete probability
Unit III: Counting and probability · Topic 9 of 13
Key idea
Discrete probability assigns a number \(p(s)\) to each outcome \(s\) of a finite (or countable) sample space \(S\), with every \(p(s) \ge 0\) and \(\sum p(s) = 1\); the probability of an event \(E \subseteq S\) is the sum over its outcomes. When outcomes are equally likely this is \(P(E) = |E| / |S|\), and probability becomes counting divided by counting. The rules for complements, unions, conditional probability and independence follow directly from the definition, and Bayes’ theorem turns a conditional probability around. A random variable attaches a number to each outcome; its expected value is the long-run average, and linearity of expectation lets you compute averages without computing whole distributions.
Basic rules.
\[P(\overline{E}) = 1 - P(E)\] \[P(E \cup F) = P(E) + P(F) - P(E \cap F)\] \[P(E \mid F) = \frac{P(E \cap F)}{P(F)}.\]Independence. \(E\) and \(F\) are independent iff \(P(E \cap F) = P(E)P(F)\), equivalently \(P(E \mid F) = P(E)\).
Bayes’ theorem.
\[P(F \mid E)\] \[= \frac{P(E \mid F)P(F)}{P(E \mid F)P(F) + P(E \mid \overline{F})P(\overline{F})}.\]Random variables. \(X : S \to \mathbb{R}\); distribution \(p(X = x)\); expected value and variance
\[E(X) = \sum_{s \in S} X(s)p(s) = \sum_x x\,p(X = x)\] \[V(X) = E(X^2) - E(X)^2.\]Linearity. \(E(X + Y) = E(X) + E(Y)\) always, independent or not; \(E(aX + b) = aE(X) + b\). For independent \(X, Y\): \(E(XY) = E(X)E(Y)\) and \(V(X + Y) = V(X) + V(Y)\).
- Bernoulli trials \(n\) independent trials with success probability \(p\): \(P(k \text{ successes}) = \binom{n}{k}p^k(1-p)^{n-k}\) (binomial distribution), mean \(np\), variance \(np(1 - p)\).
- Geometric trials until the first success: \(P(X = k) = (1 - p)^{k-1}p\), \(E(X) = 1/p\). Expected rolls to see a \(6\): \(6\).
- Indicators to count how many of several events happen, add indicator variables and use linearity: the expected number of fixed points of a random permutation of \(n\) items is \(n \cdot \tfrac1n = 1\). The same idea gives the binomial mean: \(n\) indicators, one per trial, each with expectation \(p\), add up to \(np\).
- At least one \(P(\text{at least one 6 in 4 rolls}) = 1 - (5/6)^4 = 671/1296 \approx 0.5177\).
- Dice one fair die has \(E = 3.5\) and \(V = 35/12\); the sum of two has \(E = 7\), and \(P(\text{sum} = 7) = 6/36\).
- Birthday problem \(P(\text{some shared birthday among } n) = 1 - \dfrac{365 \cdot 364 \cdots (365 - n + 1)}{365^n}\), which first passes \(\tfrac12\) at \(n = 23\).
- Monty Hall switching wins with probability \(2/3\): conditioning on the host’s informed choice is not the same as a fresh coin flip.
How to work it
- Name the sample space and check whether its outcomes are equally likely; if they are, the problem is a counting problem (\(|E|/|S|\)).
- Translate the English into events: “and” is \(\cap\), “or” is \(\cup\), “given” is a conditional, “at least one” is a complement.
- For a sequence of independent trials use the binomial or geometric formula; for drawing without replacement, count with combinations instead.
- For a “given a positive test” question, write Bayes with a tree or a table of \(10{,}000\) people, computing both branches of the denominator.
- For an expected value, either list the distribution or decompose \(X\) into simpler variables and use linearity. Check that the probabilities sum to \(1\).
Two fair dice. \(P(\text{sum} = 7) = 6/36 = 1/6\). Let \(A\) be “the first die shows \(3\)”: \(P(A \cap \{\text{sum} = 7\}) = P(\{(3, 4)\}) = 1/36 = \tfrac16 \cdot \tfrac16\), so these events are independent. For sum \(8\) they are not: \(P(\text{sum} = 8) = 5/36\), and \(\tfrac{1}{36} \ne \tfrac{5}{36} \cdot \tfrac16\). As conditionals: \(P(\text{sum} = 7 \mid A) = \tfrac{1/36}{1/6} = \tfrac16 = P(\text{sum} = 7)\), but \(P(\text{sum} = 8 \mid A) = \tfrac16 \ne \tfrac{5}{36}\): knowing the first die shows \(3\) changes the odds of an \(8\) but not of a \(7\).
Five fair coins, exactly three heads:
\[\binom{5}{3}\left(\tfrac12\right)^3\left(\tfrac12\right)^2 = \frac{10}{32} = \frac{5}{16}.\]A disease affects \(1\%\) of a population; the test detects it \(99\%\) of the time and gives a false positive \(2\%\) of the time. Given a positive test,
\[P(D \mid +) = \frac{(0.99)(0.01)}{(0.99)(0.01) + (0.02)(0.99)}\] \[= \frac{0.0099}{0.0099 + 0.0198} = \frac{0.0099}{0.0297} = \frac13.\]Two out of three positives are false, because the healthy group is \(99\) times larger than the sick group.
The same computation as a table of \(10{,}000\) people: \(100\) are sick and \(99\) of them test positive; \(9{,}900\) are healthy and \(2\%\) of them, \(198\), test positive. Among the \(99 + 198 = 297\) positives, \(99\) are sick: \(99/297 = \tfrac13\). The table makes both branches of the denominator visible.
A game pays \(\$10\) with probability \(\tfrac14\) and costs \(\$3\) to play: \(E(\text{gain}) = 10 \cdot \tfrac14 - 3 = -0.50\) dollars per play.
One fair die: \(E(X) = \tfrac16(1 + 2 + \cdots + 6) = \tfrac{21}{6} = 3.5\) and \(E(X^2) = \tfrac16(1 + 4 + 9 + 16 + 25 + 36) = \tfrac{91}{6}\), so
\[V(X) = E(X^2) - E(X)^2 = \frac{91}{6} - \frac{49}{4} = \frac{182 - 147}{12} = \frac{35}{12}.\]For the sum of two independent dice, linearity gives \(E = 7\) and independence gives \(V = 2 \cdot \tfrac{35}{12} = \tfrac{35}{6}\). Geometric: the first \(6\) appears on exactly the third roll with probability \((\tfrac56)^2 \cdot \tfrac16 = \tfrac{25}{216}\), two failures then a success.
Binomial: \(10\) shots at \(p = 0.3\) each give mean \(np = 3\) and variance \(np(1 - p) = 2.1\), and \(P(\text{exactly } 3) = \binom{10}{3}(0.3)^3(0.7)^7 \approx 0.267\). Without replacement the trials are not independent, so count instead: the probability that a five-card hand holds exactly two aces is \(\dfrac{\binom{4}{2}\binom{48}{3}}{\binom{52}{5}} = \dfrac{6 \cdot 17{,}296}{2{,}598{,}960} \approx 0.040\).
Watch out. \(P(A \mid B)\) and \(P(B \mid A)\) are different numbers (the test example has \(P(+ \mid D) = 0.99\) but \(P(D \mid +) = 1/3\)), and disjoint events are never independent unless one has probability zero: disjoint means \(P(A \cap B) = 0\), independent means \(P(A \cap B) = P(A)P(B)\). Keep “with replacement” (independent trials, powers) and “without replacement” (combinations) apart.
Practice: problems 53, 57, 58, 59, 60, 61, 62, 63, 64, 65 (the practice groups are the last entries in the contents).
Recurrence relations and growth of functions
Unit IV: Recurrences · Topic 10 of 13
Key idea
A recurrence relation defines a sequence by a rule that produces \(a_n\) from earlier terms, together with enough initial conditions to start it: \(a_n = a_{n-1} + a_{n-2}\) with \(a_0 = 0\), \(a_1 = 1\) is the Fibonacci sequence. Solving a recurrence means finding a closed form, a formula for \(a_n\) with no reference to other terms. First-order recurrences can be unrolled by iteration; linear homogeneous recurrences with constant coefficients are solved through their characteristic equation. The second half of the topic is the growth of functions: big-\(O\), big-\(\Omega\) and big-\(\Theta\) notation compares how fast two functions grow, and divide-and-conquer recurrences such as \(T(n) = 2T(n/2) + n\) describe the running time of algorithms.
Iteration. For \(a_n = a_{n-1} + d\): \(a_n = a_0 + nd\). For \(a_n = r a_{n-1}\): \(a_n = a_0 r^n\). For \(a_n = r a_{n-1} + c\) with \(r \ne 1\), unroll a few steps, spot the geometric sum, and get \(a_n = r^n a_0 + c\,\dfrac{r^n - 1}{r - 1}\).
Second-order linear homogeneous \(a_n = c_1 a_{n-1} + c_2 a_{n-2}\): try \(a_n = r^n\), which gives the characteristic equation
\[r^2 - c_1 r - c_2 = 0.\]Distinct roots \(r_1 \ne r_2\): \(a_n = \alpha r_1^n + \beta r_2^n\). Repeated root \(r_0\): \(a_n = (\alpha + \beta n)r_0^n\). Fit \(\alpha, \beta\) to the initial conditions.
Nonhomogeneous \(a_n = c_1 a_{n-1} + c_2 a_{n-2} + F(n)\): general solution \(=\) homogeneous solution \(+\) one particular solution. For constant \(F(n)\) try a constant; for \(F(n) = s^n\) try \(A s^n\) (or \(A n s^n\) if \(s\) is a characteristic root); for a polynomial try a polynomial of the same degree.
Fibonacci: \(r^2 = r + 1\), roots \(\frac{1 \pm \sqrt5}{2}\), and \(f_n = \frac{1}{\sqrt5}\left[\left(\frac{1+\sqrt5}{2}\right)^n - \left(\frac{1-\sqrt5}{2}\right)^n\right]\). Towers of Hanoi: \(H_n = 2H_{n-1} + 1\), \(H_1 = 1\), so \(H_n = 2^n - 1\).
- Big-O \(f(x)\) is \(O(g(x))\) if there are constants \(C, k\) with \(|f(x)| \le C|g(x)|\) for all \(x \gt k\). The witnesses \(C, k\) are what a proof must exhibit.
- Big-\(\Omega\) and big-\(\Theta\) \(\Omega\) is the lower bound (\(|f| \ge C|g|\)); \(\Theta\) means both, the same order of growth.
- Hierarchy \(1,\ \log n,\ n,\ n\log n,\ n^2,\ n^3,\ 2^n,\ n!,\ n^n\): each is \(O\) of the next, and none is \(O\) of the one before.
- Polynomials \(a_d n^d + \cdots + a_0\) is \(\Theta(n^d)\). A sum is \(O\) of the larger term; products multiply: \(O(f_1 f_2)\).
- Divide and conquer \(T(n) = a\,T(n/b) + f(n)\). Binary search \(T(n) = T(n/2) + 1\) is \(\Theta(\log n)\); merge sort \(T(n) = 2T(n/2) + n\) is \(\Theta(n \log n)\); \(T(n) = 2T(n/2) + 1\) is \(\Theta(n)\). With constant \(f(n)\): \(T(n)\) is \(O(n^{\log_b a})\) if \(a \gt 1\) and \(O(\log n)\) if \(a = 1\). More generally, when \(f(n) = \Theta(n^d)\) (the master theorem): \(T(n)\) is \(\Theta(n^d)\) if \(a \lt b^d\), \(\Theta(n^d \log n)\) if \(a = b^d\), and \(\Theta(n^{\log_b a})\) if \(a \gt b^d\). Merge sort has \(a = 2\), \(b = 2\), \(d = 1\), so \(a = b^d\) and \(T(n) = \Theta(n \log n)\); \(T(n) = 4T(n/2) + n\) has \(a = 4 \gt 2^1\), so \(T(n) = \Theta(n^{\log_2 4}) = \Theta(n^2)\).
- Counting operations a loop nested \(k\) deep running to \(n\) does \(\Theta(n^k)\) steps; halving the input at each step gives \(\Theta(\log n)\) steps (unroll \(T(n) = T(n/2) + 1\): after \(k\) halvings \(T(n) = T(n/2^k) + k\), and the input reaches size \(1\) when \(k = \log_2 n\)).
\(O\) is only an upper bound: “\(n\) is \(O(n^2)\)” is a true statement, just not a sharp one. Say \(\Theta\) when you mean “exactly this order.”
How to work it
- Write the recurrence as \(a_n - c_1 a_{n-1} - c_2 a_{n-2} = 0\) and read off the characteristic equation \(r^2 - c_1 r - c_2 = 0\).
- Solve for the roots. Distinct: \(a_n = \alpha r_1^n + \beta r_2^n\). Repeated: \(a_n = (\alpha + \beta n) r_0^n\).
- If there is a nonhomogeneous term, find a particular solution by the matching guess and add it.
- Substitute the initial conditions (at the indices they are given, usually \(n = 0\) and \(n = 1\)) and solve the two linear equations for \(\alpha, \beta\).
- Check the closed form against a term you can compute from the recurrence directly, such as \(a_2\).
Solve \(a_n = 5a_{n-1} - 6a_{n-2}\), \(a_0 = 1\), \(a_1 = 4\). Characteristic equation
\[r^2 - 5r + 6 = (r - 2)(r - 3) = 0\]so \(a_n = \alpha 2^n + \beta 3^n\). The initial conditions give \(\alpha + \beta = 1\) and \(2\alpha + 3\beta = 4\), hence \(\beta = 2\), \(\alpha = -1\):
\[a_n = 2 \cdot 3^n - 2^n.\]Check: the recurrence gives \(a_2 = 5(4) - 6(1) = 14\) and the formula gives \(2 \cdot 9 - 4 = 14\).
Show \(f(n) = 3n^2 + 10n + 7\) is \(O(n^2)\). For \(n \ge 1\), \(n \le n^2\) and \(1 \le n^2\), so
\[3n^2 + 10n + 7 \le 3n^2 + 10n^2 + 7n^2 = 20n^2\]and \(C = 20\), \(k = 1\) are witnesses. Since also \(f(n) \ge 3n^2\), \(f(n)\) is \(\Theta(n^2)\).
Towers of Hanoi by iteration: \(H_n = 2H_{n-1} + 1 = 2(2H_{n-2} + 1) + 1 = \cdots = 2^{n-1}H_1 + (2^{n-1} - 1) = 2^n - 1\).
Repeated root: \(a_n = 4a_{n-1} - 4a_{n-2}\), \(a_0 = 1\), \(a_1 = 4\). Then \(r^2 - 4r + 4 = (r - 2)^2\), so \(a_n = (\alpha + \beta n)2^n\); \(a_0 = \alpha = 1\) and \(a_1 = 2(1 + \beta) = 4\) give \(\beta = 1\): \(a_n = (n + 1)2^n\). Check: the recurrence gives \(a_2 = 4 \cdot 4 - 4 \cdot 1 = 12\) and the formula gives \(3 \cdot 4 = 12\).
Nonhomogeneous: \(a_n = 3a_{n-1} + 2\), \(a_0 = 1\). The homogeneous part is \(\alpha 3^n\); for the constant forcing term try a constant, \(a_n = A\): \(A = 3A + 2\) gives \(A = -1\). So \(a_n = \alpha 3^n - 1\), and \(a_0 = 1\) gives \(\alpha = 2\): \(a_n = 2 \cdot 3^n - 1\). Check: \(a_1 = 3 \cdot 1 + 2 = 5 = 2 \cdot 3 - 1\). Fit the constants only after the particular solution has been added.
When the forcing term is itself a solution of the homogeneous part, multiply the guess by \(n\). For \(a_n = 2a_{n-1} + 2^n\), \(a_0 = 1\), the guess \(A2^n\) collapses (\(A2^n = A2^n + 2^n\) has no solution), so try \(An2^n\): \(An2^n = A(n - 1)2^n + 2^n\) gives \(A = 1\). Then \(a_n = \alpha 2^n + n2^n\), and \(a_0 = 1\) gives \(\alpha = 1\): \(a_n = (n + 1)2^n\). Check: \(a_1 = 2\cdot 1 + 2 = 4\) and \(a_2 = 2\cdot 4 + 4 = 12\), matching \(2\cdot 2\) and \(3\cdot 4\).
Watch out. A repeated root does not give \(\alpha r_0^n + \beta r_0^n\), which is a single constant times \(r_0^n\) and cannot fit two initial conditions; the second solution is \(n r_0^n\). Fit the constants at the indices where the initial conditions are actually given (\(a_1, a_2\) is not \(a_0, a_1\)), and remember that proving \(f\) is \(O(g)\) requires explicit witnesses \(C\) and \(k\), not a limit you feel is obvious.
Practice: problems 72, 73, 74, 75, 76, 77, 78, 79, 80 (the practice groups are the last entries in the contents).
Graphs: paths, circuits and planarity
Unit V: Graphs, trees and Boolean algebra · Topic 11 of 13
Key idea
A graph is a set of vertices joined by edges; a simple graph has no loops and no parallel edges, and the degree of a vertex counts the edges at it. The first theorem, the handshaking theorem \(\sum \deg(v) = 2|E|\), already decides which degree sequences are possible. Paths and circuits describe how you can move through a graph: an Euler circuit uses every edge exactly once, a Hamilton circuit visits every vertex exactly once, and the two have completely different theories, one with a clean test and one without. Planarity asks whether a graph can be drawn without crossings; Euler’s formula \(v - e + f = 2\) and its corollaries give quick proofs that \(K_5\) and \(K_{3,3}\) cannot be.
Handshaking theorem. In any graph \(\sum_{v} \deg(v) = 2e\), so the degree sum is even and the number of odd-degree vertices is even.
Special graphs. Complete \(K_n\): every pair adjacent, \(\binom{n}{2}\) edges, each degree \(n - 1\). Cycle \(C_n\): \(n\) edges, all degrees \(2\). Wheel \(W_n\): \(C_n\) plus a hub, \(2n\) edges. Hypercube \(Q_n\): \(2^n\) vertices, \(n2^{n-1}\) edges. Complete bipartite \(K_{m,n}\): \(mn\) edges. The complement \(\overline{G}\) of a simple graph on \(n\) vertices has the \(\binom{n}{2} - e\) pairs that are not edges of \(G\).
Bipartite means the vertices split into two parts with every edge crossing between them; equivalently the graph has no odd cycle; equivalently it is \(2\)-colourable.
Paths and connectivity. A path is a sequence of edges joining consecutive vertices; a simple path repeats no vertex (some texts: no edge); a circuit starts and ends at the same vertex. A graph is connected when every pair of vertices is joined by a path; a cut vertex or bridge is one whose removal disconnects the graph.
Adjacency matrix \(A\): \(a_{ij} = 1\) if \(i\) and \(j\) are adjacent. The \((i, j)\) entry of \(A^k\) counts walks of length \(k\) from \(i\) to \(j\). For the path \(a\)–\(b\)–\(c\), \(A^2\) has \(2\) in the \((b, b)\) position (walks \(b\,a\,b\) and \(b\,c\,b\)), \(1\) in the \((a, c)\) position (\(a\,b\,c\)) and \(0\) in the \((a, b)\) position. Isomorphic graphs share every invariant: vertex and edge counts, degree sequence, cycle lengths, connectivity. To show two graphs are not isomorphic, name one invariant that differs; to show they are, write down the vertex correspondence explicitly and check that every edge maps to an edge.
- Euler circuit a connected multigraph has one iff every vertex has even degree. Euler path (not a circuit) iff exactly two vertices have odd degree; the path runs between them.
- Hamilton circuit no simple test. Dirac: if \(n \ge 3\) and every degree is \(\ge n/2\), one exists. Ore: \(\deg(u) + \deg(v) \ge n\) for every nonadjacent pair suffices. A vertex of degree \(1\) rules one out; at a vertex of degree \(2\) both edges must be used.
- Euler’s formula for a connected planar graph, \(v - e + f = 2\), with \(f\) counting the unbounded face.
- Planarity bounds if \(v \ge 3\): \(e \le 3v - 6\); if also there are no triangles: \(e \le 2v - 4\). Every planar graph has a vertex of degree \(\le 5\).
- Kuratowski a graph is nonplanar iff it contains a subdivision of \(K_5\) or \(K_{3,3}\).
- Chromatic number \(\chi(K_n) = n\); \(\chi = 2\) for a bipartite graph with an edge; \(\chi(C_n) = 2\) for even \(n\) and \(3\) for odd \(n\); planar graphs have \(\chi \le 4\) (the four colour theorem).
- Shortest paths Dijkstra’s algorithm grows a set of settled vertices from the source, each time settling the tentative closest one.
How to work it
- List the degrees. Odd degree sum: the graph does not exist. Zero odd vertices (and connected): Euler circuit. Exactly two: Euler path between them. More: neither.
- To find the circuit, use Fleury: walk the edges, never crossing a bridge unless it is the only edge left, or splice together smaller circuits.
- For planarity, first try to draw it without crossings (move vertices, route edges around the outside).
- If that fails, count: compute \(3v - 6\) (or \(2v - 4\) with no triangles) and compare with \(e\); if \(e\) exceeds the bound the graph is not planar.
- If \(e\) is within the bound, the test is inconclusive; look for a \(K_5\) or \(K_{3,3}\) subdivision instead.
A graph has degree sequence \(3, 3, 2, 2, 2\). The sum is \(12\), so it has \(6\) edges, and exactly two vertices are odd: if it is connected it has an Euler path between the two degree-\(3\) vertices but no Euler circuit. By contrast \(K_4\) has four vertices of degree \(3\), so it has neither; it is planar (draw one vertex inside the triangle of the other three), and Euler’s formula checks:
\[v - e + f = 4 - 6 + 4 = 2.\]\(K_5\) has \(v = 5\), \(e = 10\), and \(3v - 6 = 9 \lt 10\): not planar. \(K_{3,3}\) has \(v = 6\), \(e = 9\) and no triangles (it is bipartite), so the sharper bound applies: \(2v - 4 = 8 \lt 9\), not planar. The weaker bound \(3v - 6 = 12\) would not have caught it.
Five vertices all of degree \(3\) is impossible: the degree sum \(15\) is odd. And \(C_5\) needs three colours: alternating two colours around an odd cycle ends with two adjacent vertices the same.
Dijkstra. Weighted edges \(AB = 1\), \(AC = 4\), \(BC = 2\), \(BD = 5\), \(CD = 1\); shortest distances from \(A\). Start with \(A = 0\) and every other label \(\infty\). Settle \(A\) and update its neighbours: \(B = 1\), \(C = 4\). Settle \(B\) (the smallest unsettled label): through \(B\), \(C = \min(4,\ 1 + 2) = 3\) and \(D = 1 + 5 = 6\). Settle \(C\): \(D = \min(6,\ 3 + 1) = 4\). Settle \(D\). Final distances \(A\colon 0\), \(B\colon 1\), \(C\colon 3\), \(D\colon 4\), and the shortest route to \(D\) is \(A\)–\(B\)–\(C\)–\(D\), not the two-edge route \(A\)–\(B\)–\(D\) of weight \(6\). A label is final only when its vertex is settled; earlier values are tentative.
Building an Euler circuit. Two triangles \(ABC\) and \(CDE\) sharing the vertex \(C\) (a bow tie) have degrees \(2, 2, 4, 2, 2\), all even, and the graph is connected, so a circuit exists. Start at \(A\) and walk a circuit: \(A \to B \to C \to A\). Edges \(CD, DE, EC\) are unused and all touch \(C\), which is on the circuit, so walk the second circuit \(C \to D \to E \to C\) and splice it in at \(C\): \(A \to B \to C \to D \to E \to C \to A\). Six edges, each used once, back at the start. The same splicing works on any connected even-degree graph, because the unused edges always form circuits that meet the one already found. The same bow tie has no Hamilton circuit: \(C\) is a cut vertex, and a circuit visiting every vertex exactly once would have to pass through \(C\) twice to reach both triangles.
Watch out. The inequalities \(e \le 3v - 6\) and \(e \le 2v - 4\) are necessary conditions, not tests: a graph can satisfy them and still be nonplanar (\(K_{3,3}\) passes the first). Euler’s theorems also need connectivity, so check it before reading off degrees, and do not confuse Euler (every edge once) with Hamilton (every vertex once); a graph can have either without the other.
Practice: problems 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 93, 94, 95, 96 (the practice groups are the last entries in the contents).
Trees and spanning trees
Unit V: Graphs, trees and Boolean algebra · Topic 12 of 13
Key idea
A tree is a connected graph with no cycles, and that one definition forces a surprising amount: there is exactly one simple path between any two vertices, every tree with \(n\) vertices has exactly \(n - 1\) edges, and removing any edge disconnects it. Choosing a root turns a tree into a family diagram with parents, children, leaves and levels, which is how data structures, decision procedures and expression parsing are drawn. A spanning tree of a connected graph keeps all the vertices and just enough edges to stay connected; when the edges have weights, the minimum spanning tree is the cheapest such choice, and Kruskal’s and Prim’s algorithms find it greedily, one safe edge at a time.
Equivalent definitions. For a graph with \(n\) vertices the following are equivalent: it is a tree; it is connected with \(n - 1\) edges; it is acyclic with \(n - 1\) edges; any two vertices are joined by exactly one simple path. A forest (acyclic, \(k\) components) has \(n - k\) edges. Every tree with \(n \ge 2\) vertices has at least two leaves.
Rooted trees. Fix a root; each other vertex has a unique parent, the vertex before it on the path to the root. Vertices with no children are leaves, the rest are internal. The level of \(v\) is its distance from the root; the height is the largest level. An \(m\)-ary tree has at most \(m\) children per vertex; a full \(m\)-ary tree has exactly \(0\) or \(m\).
Full \(m\)-ary tree with \(i\) internal vertices.
\[n = mi + 1 \text{ vertices}\] \[l = (m - 1)i + 1 \text{ leaves}\] \[l = \frac{(m-1)n + 1}{m}.\]An \(m\)-ary tree of height \(h\) has at most \(m^h\) leaves, so \(h \ge \lceil \log_m l \rceil\).
Where the formulas come from: every vertex except the root is a child of exactly one internal vertex, and each internal vertex has \(m\) children, so \(n - 1 = mi\); then the leaves are what is left, \(l = n - i = (m - 1)i + 1\). For example a full binary tree (\(m = 2\)) with \(l = 8\) leaves has \(i = 7\) internal vertices, \(n = 15\) vertices, and height at least \(\lceil \log_2 8 \rceil = 3\).
Traversals of a rooted ordered tree: preorder (root, then subtrees), inorder (left subtree, root, right subtree), postorder (subtrees, then root). Preorder of an expression tree gives prefix (Polish) notation, postorder gives postfix. For \((a + b) \cdot c\) the root is \(\cdot\) with children \(+\) (over \(a\), \(b\)) and \(c\): preorder \(\cdot\ +\ a\ b\ c\), inorder \(a + b \cdot c\) (ambiguous without parentheses), postorder \(a\ b\ +\ c\ \cdot\).
- Existence every connected graph has a spanning tree; a connected graph with \(n\) vertices and \(e\) edges needs \(e - (n - 1)\) edges removed to get one, each removal breaking a cycle.
- Building one depth-first search (go deep, backtrack) or breadth-first search (level by level) from any start vertex; the tree edges are the ones that discover new vertices.
- Kruskal sort the edges by weight; take each edge in turn unless it closes a cycle; stop at \(n - 1\) edges.
- Prim start at any vertex; repeatedly add the cheapest edge joining the tree to a new vertex; stop at \(n - 1\) edges.
- Correctness both are greedy and both are correct: the cheapest edge across any cut belongs to some minimum spanning tree. With distinct weights the MST is unique; with ties, different MSTs share the same total weight.
- Cayley \(K_n\) has \(n^{n-2}\) spanning trees (\(K_4\): \(16\)).
- Decision trees a binary tree with \(l\) leaves has height \(\ge \lceil \log_2 l \rceil\), so sorting \(n\) items by comparisons needs at least \(\lceil \log_2 n! \rceil\) comparisons (\(7\) for \(n = 5\)).
How to work it
- List every edge with its weight and sort them from lightest to heaviest; keep a running list of which vertices are already connected to each other (the components).
- Take the lightest unused edge. If its endpoints are in different components, add it and merge the components; if they are already in the same component, it would close a cycle, so skip it.
- Repeat until \(n - 1\) edges have been added; every remaining edge would close a cycle.
- Add up the weights for the total, and state the tree as its edge list.
- For Prim, do the same but only consider edges with exactly one endpoint in the current tree; the final weight must agree.
Vertices \(A, B, C, D, E\) with edges \(AB = 1\), \(BD = 2\), \(AC = 3\), \(BC = 4\), \(CD = 5\), \(DE = 6\), \(CE = 7\). Kruskal in weight order:
\[AB\ (1)\ \checkmark,\quad BD\ (2)\ \checkmark,\quad AC\ (3)\ \checkmark,\quad BC\ (4)\ \times,\quad CD\ (5)\ \times,\quad DE\ (6)\ \checkmark.\]\(BC\) is skipped because \(B\) and \(C\) are already joined through \(A\); \(CD\) because \(C, A, B, D\) are all connected by then. After \(DE\) there are \(4 = n - 1\) edges, so \(CE\) is never considered. The minimum spanning tree is \(\{AB, BD, AC, DE\}\) with weight
\[1 + 2 + 3 + 6 = 12.\]Prim from \(A\) adds \(AB, BD, AC, DE\) in that order and reaches the same tree.
Spanning trees by search. Take the unweighted graph on \(1, \dots, 5\) with edges \(12, 13, 24, 25, 34\). Breadth-first from \(1\): discover \(2\) and \(3\) (level 1), then from \(2\) discover \(4\) and \(5\) (level 2); from \(3\), vertex \(4\) is already seen. Tree edges \(12, 13, 24, 25\); the leftover edge \(34\) closes the cycle \(1\)–\(2\)–\(4\)–\(3\)–\(1\). Depth-first from \(1\): go \(1 \to 2 \to 4 \to 3\), dead end, back up to \(2\), then \(2 \to 5\). Tree edges \(12, 24, 43, 25\); now \(13\) is the leftover. Both trees have \(n - 1 = 4\) edges and \(e - (n - 1) = 5 - 4 = 1\) edge removed, as the count predicts; a graph usually has many spanning trees and each search finds one.
A full \(3\)-ary tree with \(4\) internal vertices has \(n = 3 \cdot 4 + 1 = 13\) vertices and \(l = 2 \cdot 4 + 1 = 9\) leaves; check \(13 - 4 = 9\). A spanning tree of \(K_5\) keeps \(4\) of the \(10\) edges, so \(6\) are removed.
Watch out. “\(n - 1\) edges” alone does not make a tree: a triangle plus a disjoint edge has \(5\) vertices and \(4\) edges but is neither connected nor acyclic. In Kruskal, skipping an edge means its endpoints are already connected, not that the edge is heavy; and when weights tie, two correct runs can produce different trees of the same total weight, so always report your tree together with its weight.
Practice: problems 89, 90, 91, 92, 95 (the practice groups are the last entries in the contents).
Boolean algebra and logic circuits
Unit V: Graphs, trees and Boolean algebra · Topic 13 of 13
Key idea
Boolean algebra is the arithmetic of the two values \(0\) and \(1\) with three operations: complement \(\overline{x}\), Boolean sum \(x + y\) (OR) and Boolean product \(xy\) (AND). It is propositional logic written so that it looks like algebra, and the identities (De Morgan, distributive, absorption) are the same laws under new names. A Boolean function \(F(x_1, \dots, x_n)\) is specified by a truth table and can always be written as a sum of products of literals, which is what a circuit of AND, OR and NOT gates computes. The engineering question is minimization: find an equivalent expression with as few terms and literals as possible, which is what Karnaugh maps do for up to four variables.
Identities (each has a dual with \(+\) and \(\cdot\), \(0\) and \(1\) swapped; e.g. the dual of \(x + \overline{x}y = x + y\) is \(x(\overline{x} + y) = xy\)):
\[x + 0 = x,\ \ x \cdot 1 = x\] \[x + 1 = 1,\ \ x \cdot 0 = 0\] \[x + x = x,\ \ xx = x\] \[x + \overline{x} = 1,\ \ x\overline{x} = 0\] \[\overline{\overline{x}} = x\] \[x + yz = (x + y)(x + z)\] \[x(y + z) = xy + xz\] \[x + xy = x\] \[\overline{x + y} = \overline{x}\,\overline{y}\] \[\overline{xy} = \overline{x} + \overline{y}.\]Also the commutative and associative laws, and the useful \(x + \overline{x}y = x + y\).
Sum-of-products expansion. A minterm is a product containing every variable exactly once, plain or complemented, such as \(x\overline{y}z\); it equals \(1\) on exactly one row of the table. Any \(F\) is the sum of the minterms of the rows where \(F = 1\) (disjunctive normal form). Dually, \(F\) is a product of maxterms (conjunctive normal form).
For \(F = x \oplus y\) the table has \(F = 1\) on the rows \(xy = 01\) and \(10\), so the sum of products is \(\overline{x}y + x\overline{y}\). The rows with \(F = 0\) are \(00\) and \(11\), giving the product of maxterms \((x + y)(\overline{x} + \overline{y})\); multiplying out and using \(x\overline{x} = 0\) returns \(x\overline{y} + \overline{x}y\).
Three variables: the majority function (\(1\) when at least two inputs are \(1\)) has minterms \(011, 101, 110, 111\), so \(F = \overline{x}yz + x\overline{y}z + xy\overline{z} + xyz\). Pairing \(xyz\) with each of the other three (\(\overline{x}yz + xyz = yz\), and likewise \(xz\) and \(xy\)) gives the minimal form \(F = xy + xz + yz\); on the K-map these are three overlapping blocks of two that all share the cell \(111\).
There are \(2^{2^n}\) Boolean functions of \(n\) variables: \(16\) of two variables, \(256\) of three.
- Gates AND (\(xy\)), OR (\(x + y\)), inverter (\(\overline{x}\)); NAND \(\overline{xy}\) and NOR \(\overline{x + y}\); XOR \(x \oplus y = x\overline{y} + \overline{x}y\).
- Functional completeness \(\{\text{AND}, \text{OR}, \text{NOT}\}\) builds everything; so does \(\{\text{AND}, \text{NOT}\}\) or \(\{\text{OR}, \text{NOT}\}\) by De Morgan, and NAND alone does: \(\overline{x} = x \uparrow x\) and \(xy = (x \uparrow y) \uparrow (x \uparrow y)\); OR then follows from De Morgan, \(x + y = \overline{\overline{x}\,\overline{y}} = (x \uparrow x) \uparrow (y \uparrow y)\).
- Table to circuit write the sum of products, simplify, then draw one AND gate per product feeding one OR gate, with inverters on the complemented inputs.
- Half adder sum \(= x \oplus y\), carry \(= xy\) (check \(1 + 1\): sum \(0\), carry \(1\), i.e. \(10_2\)). Full adder sum \(= x \oplus y \oplus c\), carry \(= xy + c(x \oplus y)\).
- Karnaugh map a grid with one cell per minterm, arranged so that neighbouring cells differ in one variable (two variables: \(2 \times 2\); three: \(2 \times 4\) with columns \(yz = 00, 01, 11, 10\); four: \(4 \times 4\)). The left and right edges (and the top and bottom) count as adjacent.
- Reading a map circle blocks of \(1\)s of size \(1, 2, 4, 8\) that are rectangles (wrapping allowed); each block is the product of the variables that are constant on it; the minimal expression uses the fewest, largest blocks that cover every \(1\). Blocks may overlap, and don’t-care cells may be used or ignored.
How to work it
- Build the truth table or list the minterms where \(F = 1\), numbering rows by the binary value of \(xyz\).
- Draw the \(2 \times 4\) map: rows \(x = 0, 1\), columns \(yz = 00, 01, 11, 10\) (Gray code order, so adjacent columns differ in one bit), and write a \(1\) in each minterm cell.
- Circle the largest possible blocks of \(1\)s (size \(4\), then \(2\), then \(1\)), including wrap-around blocks, until every \(1\) is covered; prefer blocks that cover a \(1\) no other block covers.
- Write each block as the product of the variables that do not change inside it; a size-\(4\) block in a three-variable map is a single literal.
- Sum the block products, then verify against the original table on at least the rows where \(F = 0\).
Let \(F(x, y, z) = 1\) exactly on the rows \(xyz = 001, 011, 101, 110, 111\) (minterms \(m_1, m_3, m_5, m_6, m_7\)). As a sum of products,
\[F = \overline{x}\,\overline{y}z + \overline{x}yz + x\overline{y}z + xy\overline{z} + xyz.\]Algebra. The four terms containing \(z\) combine: \(\overline{x}\,\overline{y}z + \overline{x}yz + x\overline{y}z + xyz = z(\overline{x}\,\overline{y} + \overline{x}y + x\overline{y} + xy) = z \cdot 1 = z\). Then \(F = z + xy\overline{z}\), and the identity \(x + \overline{x}y = x + y\) with \(z\) in the role of \(x\) and \(xy\) in the role of \(y\) gives
\[F = z + xy.\]K-map. In the \(2 \times 4\) map the \(1\)s fill the two middle columns (\(yz = 01, 11\)) in both rows, a block of four on which only \(z = 1\) is constant, plus the cell \(x = 1\), \(yz = 10\), which pairs with its neighbour \(x = 1\), \(yz = 11\) to make the block \(xy\). Same answer, \(F = z + xy\): two gates and no inverters instead of five three-input AND gates.
Check a zero row: at \(xyz = 100\), \(z + xy = 0 + 0 = 0\), and \(F = 0\) there as required.
Watch out. In Boolean algebra \(1 + 1 = 1\), and \(x + xy\) simplifies to \(x\), not to \(x(1 + y)\) left as a product. When complementing, De Morgan flips the operation as well as each variable: \(\overline{xy + z} = (\overline{x} + \overline{y})\,\overline{z}\). On a Karnaugh map every block must be a rectangle whose size is a power of two, and the first and last columns are neighbours, so a pair split across the two edges still counts as a block.
Practice: problems 97, 98, 99, 100 (the practice groups are the last entries in the contents).
Set 1: logic, sets and functions
Discrete Math · Practice problems 1 to 20
Problems 1 to 20
One hundred problems modelled on a first discrete mathematics course. Every problem opens to a full, step-by-step solution with the final answer highlighted. Try it on paper first; the Review link at the end jumps back to the matching notes.
1Construct the truth table for the compound proposition \((p \lor q) \to r\). In how many of its eight rows is the proposition true?
Solution
Three propositional variables give \(2^3 = 8\) rows. Rather than filling in every column, use the one fact that decides an implication: \(A \to B\) is false exactly when \(A\) is true and \(B\) is false, and true in every other row.
Here the hypothesis is \(p \lor q\), which is true in every row except the one with \(p = q = \mathrm{F}\). So \((p \lor q) \to r\) is false precisely in the rows where \(p \lor q\) is true and \(r\) is false:
\[(p, q, r) = (\mathrm{T}, \mathrm{T}, \mathrm{F}),\ (\mathrm{T}, \mathrm{F}, \mathrm{F}),\ (\mathrm{F}, \mathrm{T}, \mathrm{F}).\]Those are the only three false rows. Every row with \(r = \mathrm{T}\) (four rows) is true because the conclusion holds, and the row \((\mathrm{F}, \mathrm{F}, \mathrm{F})\) is true because the hypothesis fails. That gives
\[8 - 3 = 5 \text{ true rows}.\]Check by direct count: four rows with \(r = \mathrm{T}\), plus the single row \((\mathrm{F}, \mathrm{F}, \mathrm{F})\), equals five.
\(5\) of the \(8\) rows are true
Review:
2Classify each compound proposition as a tautology, a contradiction or a contingency: (a) \(\big(p \land (p \to q)\big) \to q\); (b) \((p \to q) \land (p \land \lnot q)\); (c) \((p \to q) \to (q \to p)\).
Solution
(a) Try to make it false. The implication is false only if the hypothesis \(p \land (p \to q)\) is true and the conclusion \(q\) is false. The hypothesis forces \(p = \mathrm{T}\) and \(p \to q = \mathrm{T}\); with \(p\) true, \(p \to q\) is true only if \(q = \mathrm{T}\). But then the conclusion \(q\) is true, not false. No row makes it false, so it is a tautology. (This is the rule modus ponens written as a single proposition.)
(b) Rewrite the second conjunct: \(p \land \lnot q\) is exactly the negation of \(p \to q\), because an implication fails precisely when \(p\) is true and \(q\) is false. So the proposition is
\[(p \to q) \land \lnot(p \to q)\]which has the form \(A \land \lnot A\) and is false in every row: a contradiction.
(c) This says “an implication implies its converse,” which is sometimes true and sometimes false. With \(p = \mathrm{F}\), \(q = \mathrm{T}\): \(p \to q\) is true but \(q \to p\) is false, so the whole proposition is false. With \(p = q = \mathrm{T}\) both implications are true and the proposition is true. Since it takes both values it is a contingency.
(a) tautology; (b) contradiction; (c) contingency
Review:
3(a) Which proposition is logically equivalent to \(\lnot(p \to q)\)? (i) \(\lnot p \to \lnot q\); (ii) \(p \to \lnot q\); (iii) \(p \land \lnot q\); (iv) \(\lnot p \lor q\). (b) In the truth table of \(p \to (q \land r)\), how many of the eight rows make the proposition false?
Solution
(a) Start from the standard rewriting of an implication as a disjunction, then apply De Morgan’s law:
\[\lnot(p \to q) \equiv \lnot(\lnot p \lor q) \equiv \lnot\lnot p \land \lnot q \equiv p \land \lnot q.\]So the answer is (iii). The others are traps: (iv) \(\lnot p \lor q\) is \(p \to q\) itself, not its negation; (i) is the inverse of \(p \to q\), which is equivalent to the converse, not to the negation; (ii) \(p \to \lnot q\) is true when \(p\) is false, while \(\lnot(p \to q)\) is false there.
(b) \(p \to (q \land r)\) is false exactly when \(p\) is true and \(q \land r\) is false. With \(p = \mathrm{T}\) fixed, the pair \((q, r)\) has four possibilities, and \(q \land r\) is false in three of them: \((\mathrm{T}, \mathrm{F})\), \((\mathrm{F}, \mathrm{T})\), \((\mathrm{F}, \mathrm{F})\). So the proposition is false in
\[3 \text{ rows}\]and true in the other \(8 - 3 = 5\).
(a) (iii) \(p \land \lnot q\); (b) \(3\) rows
Review:
4(a) The domain of \(x\) and \(y\) is the real numbers. Which statement is the negation of \(\forall x\,\exists y\,(x + y = 0)\)? (i) \(\exists x\,\exists y\,(x + y \ne 0)\); (ii) \(\exists x\,\forall y\,(x + y \ne 0)\); (iii) \(\forall x\,\exists y\,(x + y \ne 0)\); (iv) \(\forall x\,\forall y\,(x + y \ne 0)\). (b) Which sentence is the negation of “Every student in the class has taken calculus or statistics”? (i) Every student in the class has taken neither calculus nor statistics. (ii) No student in the class has taken both calculus and statistics. (iii) Some student in the class has taken neither calculus nor statistics. (iv) Some student in the class has taken both calculus and statistics.
Solution
(a) Push the negation inward one quantifier at a time, flipping each quantifier as the negation passes it: \(\lnot\forall\) becomes \(\exists\lnot\) and \(\lnot\exists\) becomes \(\forall\lnot\).
\[\lnot\,\forall x\,\exists y\,(x + y = 0) \equiv \exists x\,\lnot\exists y\,(x + y = 0) \equiv \exists x\,\forall y\,\lnot(x + y = 0) \equiv \exists x\,\forall y\,(x + y \ne 0).\]That is (ii). In words: the original says every number has an additive inverse (true, take \(y = -x\)); the negation says some number has no additive inverse at all. Choice (i) is far too weak (it only needs one pair with nonzero sum), and (iii) and (iv) keep a \(\forall x\), which a negation of \(\forall x\) can never do.
(b) The sentence has the form \(\forall s\,(C(s) \lor S(s))\). Its negation is \(\exists s\,\lnot(C(s) \lor S(s))\), and by De Morgan \(\lnot(C \lor S) \equiv \lnot C \land \lnot S\). So the negation is
\[\exists s\,(\lnot C(s) \land \lnot S(s)):\]“Some student has taken neither calculus nor statistics,” choice (iii). Choice (i) is much stronger than the negation, and (ii) and (iv) talk about “both,” which negates an and, not an or.
(a) (ii) \(\exists x\,\forall y\,(x + y \ne 0)\); (b) (iii) some student has taken neither
Review:
5The domain of every variable is the set of integers \(\mathbb{Z}\). How many of the following four statements are true? (i) \(\forall x\,(x^2 \ge x)\); (ii) \(\exists x\,(2x = 7)\); (iii) \(\forall x\,\exists y\,(x + y = 0)\); (iv) \(\exists y\,\forall x\,(xy = x)\).
Solution
Decide each statement separately, remembering that the domain is the integers, not the reals.
(i) True. \(x^2 - x = x(x - 1)\). For an integer \(x \le 0\) both factors are \(\le 0\), so the product is \(\ge 0\); for \(x \ge 1\) both factors are \(\ge 0\). (Over the reals this would be false, for example \(x = \tfrac12\), but no integer lies strictly between 0 and 1.)
(ii) False. \(2x = 7\) forces \(x = \tfrac72\), which is not an integer. An existence claim fails when no element of the domain works.
(iii) True. Whatever \(x\) is chosen, \(y = -x\) is an integer and \(x + (-x) = 0\). Note the order: \(y\) may depend on \(x\).
(iv) True. Here one \(y\) must work for every \(x\). Take \(y = 1\): then \(x\cdot 1 = x\) for all integers \(x\).
Three of the four statements are true:
\[\text{(i), (iii), (iv)}\] \[\Longrightarrow\ 3.\]\(3\) (statements (i), (iii) and (iv) are true; (ii) is false)
Review:
6(a) An argument has premises \(p \to q\) and \(\lnot q\) and conclusion \(\lnot p\). Which rule of inference is being used? (i) modus ponens; (ii) modus tollens; (iii) hypothetical syllogism; (iv) disjunctive syllogism. (b) Which statement is the contrapositive of “If \(n\) is even, then \(n^2\) is even”? (i) If \(n\) is odd, then \(n^2\) is odd. (ii) If \(n^2\) is even, then \(n\) is even. (iii) If \(n^2\) is odd, then \(n\) is odd. (iv) \(n\) is even and \(n^2\) is odd.
Solution
(a) The pattern “from \(p \to q\) and \(\lnot q\), conclude \(\lnot p\)” is modus tollens (denying the consequent). It is valid because \(p \to q\) is equivalent to its contrapositive \(\lnot q \to \lnot p\), and then modus ponens applied to \(\lnot q \to \lnot p\) and \(\lnot q\) gives \(\lnot p\):
\[\big((p \to q) \land \lnot q\big) \to \lnot p \quad\text{is a tautology.}\]Modus ponens would need the premise \(p\); hypothetical syllogism chains two implications; disjunctive syllogism starts from \(p \lor q\).
(b) Write the statement as \(E(n) \to E(n^2)\). Its contrapositive negates both sides and reverses the arrow: \(\lnot E(n^2) \to \lnot E(n)\), that is, “If \(n^2\) is odd, then \(n\) is odd,” choice (iii). Choice (ii) is the converse (arrow reversed only), choice (i) is the inverse (both negated, arrow kept), and (iv) is the negation of the statement. Only the contrapositive is equivalent to the original.
(a) (ii) modus tollens; (b) (iii) if \(n^2\) is odd, then \(n\) is odd
Review: ·
7Let the universal set be \(U = \{1, 2, 3, \dots, 10\}\), \(A = \{1, 2, 3, 5, 8\}\) and \(B = \{2, 3, 5, 7\}\). Find (a) \(A \cap B\); (b) \(A - B\); (c) the symmetric difference \(A \oplus B\); (d) \(\overline{A \cup B}\), the complement of \(A \cup B\).
Solution
With explicit sets, just test each element against the definition.
(a) The intersection keeps the elements in both sets:
\[A \cap B = \{2, 3, 5\}.\](b) The difference \(A - B\) keeps the elements of \(A\) that are not in \(B\). Remove \(2, 3, 5\) from \(A\):
\[A - B = \{1, 8\}.\](c) The symmetric difference contains the elements in exactly one of the two sets, \(A \oplus B = (A - B) \cup (B - A)\). We have \(A - B = \{1, 8\}\) and \(B - A = \{7\}\), so
\[A \oplus B = \{1, 7, 8\}.\](d) First the union, \(A \cup B = \{1, 2, 3, 5, 7, 8\}\), then everything in \(U\) that is missing from it:
\[\overline{A \cup B} = \{4, 6, 9, 10\}.\]Check with De Morgan: \(\overline{A} = \{4, 6, 7, 9, 10\}\), \(\overline{B} = \{1, 4, 6, 8, 9, 10\}\), and \(\overline{A} \cap \overline{B} = \{4, 6, 9, 10\}\), the same set.
(a) \(\{2, 3, 5\}\); (b) \(\{1, 8\}\); (c) \(\{1, 7, 8\}\); (d) \(\{4, 6, 9, 10\}\)
Review:
8Let \(A\) and \(B\) be finite sets with \(|A| = 4\) and \(|B| = 6\). Find (a) \(|\mathcal{P}(A)|\), the number of subsets of \(A\); (b) \(|A \times B|\); (c) \(|\mathcal{P}(A) \times \mathcal{P}(B)|\).
Solution
(a) A subset of \(A\) is built by deciding, for each of the 4 elements, whether it is in or out: two choices per element, so
\[|\mathcal{P}(A)| = 2^{4} = 16.\](b) The Cartesian product consists of ordered pairs \((a, b)\) with \(a \in A\) and \(b \in B\). There are 4 choices for \(a\) and 6 for \(b\):
\[|A \times B| = 4\cdot 6 = 24.\](c) This is the product of two power sets, so count the pairs (a subset of \(A\), a subset of \(B\)):
\[|\mathcal{P}(A) \times \mathcal{P}(B)| = |\mathcal{P}(A)|\cdot|\mathcal{P}(B)| = 2^{4}\cdot 2^{6} = 16\cdot 64 = 1024.\]Do not confuse this with \(\mathcal{P}(A \times B)\), the set of all subsets of the 24 pairs, which has \(2^{24} = 16{,}777{,}216\) elements.
(a) \(16\); (b) \(24\); (c) \(1024\)
Review:
9In a class of 120 students, 65 are taking Spanish, 48 are taking French, and 22 are taking both languages. (a) How many students are taking neither language? (b) How many are taking exactly one of the two languages?
Solution
Let \(S\) and \(F\) be the sets of students taking Spanish and French. Adding \(|S| + |F|\) counts the 22 students in both languages twice, so inclusion–exclusion corrects for that:
\[|S \cup F| = |S| + |F| - |S \cap F| = 65 + 48 - 22 = 91.\](a) The students taking neither language are the ones outside \(S \cup F\):
\[120 - 91 = 29.\](b) “Exactly one” means in \(S\) but not \(F\), or in \(F\) but not \(S\). Those counts are \(65 - 22 = 43\) and \(48 - 22 = 26\):
\[43 + 26 = 69.\]Equivalently \(|S \cup F| - |S \cap F| = 91 - 22 = 69\). Check that the four regions add up: \(43 + 22 + 26 + 29 = 120\).
(a) \(29\) students; (b) \(69\) students
Review:
10(a) How many integers from 1 to 1000 are divisible by 2, by 3, or by 5? (b) How many integers from 1 to 1000 are divisible by none of 2, 3 and 5?
Solution
Let \(A_2, A_3, A_5\) be the sets of integers in \(\{1, \dots, 1000\}\) divisible by 2, 3 and 5. The number of multiples of \(d\) up to 1000 is \(\lfloor 1000/d \rfloor\), and a number lies in two of the sets exactly when it is divisible by the product of the two primes.
\[|A_2| = 500,\quad |A_3| = 333,\quad |A_5| = 200\] \[|A_2 \cap A_3| = \lfloor 1000/6 \rfloor = 166,\quad |A_2 \cap A_5| = \lfloor 1000/10 \rfloor = 100,\quad |A_3 \cap A_5| = \lfloor 1000/15 \rfloor = 66\] \[|A_2 \cap A_3 \cap A_5| = \lfloor 1000/30 \rfloor = 33.\](a) Inclusion–exclusion for three sets adds the singles, subtracts the pairs and adds back the triple:
\[|A_2 \cup A_3 \cup A_5| = (500 + 333 + 200) - (166 + 100 + 66) + 33 = 1033 - 332 + 33 = 734.\](b) The integers divisible by none of them are the complement:
\[1000 - 734 = 266.\]Sanity check: among any 30 consecutive integers, \(30\cdot\tfrac12\cdot\tfrac23\cdot\tfrac45 = 8\) are coprime to 30, so about \(1000\cdot\tfrac{8}{30} \approx 267\) is expected.
(a) \(734\); (b) \(266\)
Review: ·
11Let \(A = \{1, 2, 3\}\) and \(B = \{a, b\}\). (a) How many elements does \(A \times B\) have? (b) How many elements does \(B \times A \times B\) have? (c) How many different relations from \(A\) to \(B\) are there?
Solution
(a) \(A \times B\) is the set of ordered pairs \((x, y)\) with \(x \in A\), \(y \in B\). Listing them: \((1,a), (1,b), (2,a), (2,b), (3,a), (3,b)\), so
\[|A \times B| = 3\cdot 2 = 6.\](b) Ordered triples \((y_1, x, y_2)\) with \(y_1, y_2 \in B\) and \(x \in A\). Multiply the sizes:
\[|B \times A \times B| = 2\cdot 3\cdot 2 = 12.\](c) A relation from \(A\) to \(B\) is, by definition, any subset of \(A \times B\). Since \(A \times B\) has 6 elements, the number of subsets is
\[2^{6} = 64.\]This includes the empty relation and the full relation \(A \times B\) itself. (Only \(2^3 = 8\) of these 64 relations are functions from \(A\) to \(B\), namely the ones that pair each element of \(A\) with exactly one element of \(B\).)
(a) \(6\); (b) \(12\); (c) \(64\)
Review: ·
12Subsets of \(U = \{1, 2, 3, 4, 5, 6\}\) are stored as bit strings of length 6, where bit \(i\) is 1 exactly when \(i\) is in the subset. Let \(A\) have bit string \(101100\) and \(B\) have bit string \(011010\). Give the bit strings of (a) \(A \cup B\); (b) \(A \cap B\); (c) \(\overline{A}\), the complement of \(A\).
Solution
Decode first to see what the strings mean: \(A = \{1, 3, 4\}\) and \(B = \{2, 3, 5\}\). Set operations become bitwise operations on the strings, position by position.
(a) Union is a bitwise OR: a 1 wherever either string has a 1.
\[101100 \lor 011010 = 111110\] \[A \cup B = \{1, 2, 3, 4, 5\}.\](b) Intersection is a bitwise AND: a 1 only where both strings have a 1. Only position 3 qualifies.
\[101100 \land 011010 = 001000\] \[A \cap B = \{3\}.\](c) The complement flips every bit.
\[\overline{101100} = 010011\] \[\overline{A} = \{2, 5, 6\}.\]Keep the leading zeros: the string must have exactly six bits, one for each element of \(U\).
(a) \(111110\); (b) \(001000\); (c) \(010011\)
Review:
13Classify each function as injective only, surjective only, bijective, or neither: (a) \(f: \mathbb{Z} \to \mathbb{Z}\), \(f(n) = 2n + 1\); (b) \(g: \mathbb{R} \to \mathbb{R}\), \(g(x) = x^3 - x\); (c) \(h: \mathbb{R} \to \mathbb{R}\), \(h(x) = 3x - 7\); (d) \(k: \mathbb{Z} \to \mathbb{Z}\), \(k(n) = n^2\).
Solution
Injective (one-to-one) means different inputs give different outputs; surjective (onto) means every element of the codomain is hit. Both depend on the stated domain and codomain, not just on the formula.
(a) If \(2a + 1 = 2b + 1\) then \(a = b\), so \(f\) is injective. But \(2n + 1\) is always odd, so even integers such as \(0\) are never outputs: not surjective. Injective only.
(b) \(g(0) = g(1) = g(-1) = 0\), so \(g\) is not injective. It is surjective: \(g\) is a continuous polynomial of odd degree, so \(g(x) \to -\infty\) as \(x \to -\infty\) and \(g(x) \to +\infty\) as \(x \to +\infty\), and by the intermediate value theorem every real value is attained. Surjective only.
(c) \(3a - 7 = 3b - 7\) forces \(a = b\), and for any real \(y\) the input \(x = (y + 7)/3\) satisfies \(h(x) = y\). So \(h\) is both, i.e. bijective, with inverse \(h^{-1}(y) = (y + 7)/3\).
(d) \(k(-1) = k(1) = 1\), so not injective; and no integer squares to \(-1\), so not surjective. Neither.
(a) injective only; (b) surjective only; (c) bijective; (d) neither
Review:
14The function \(f: \mathbb{R} - \{1\} \to \mathbb{R} - \{2\}\) given by \(f(x) = \dfrac{2x + 3}{x - 1}\) is a bijection. (a) Find a formula for \(f^{-1}(x)\). (b) Compute \(f^{-1}(5)\).
Solution
(a) Write \(y = f(x)\), solve for \(x\) in terms of \(y\), then swap the names. Clear the denominator and gather the \(x\) terms:
\[y(x - 1) = 2x + 3\] \[\Longrightarrow\ yx - 2x = y + 3\] \[\Longrightarrow\ x(y - 2) = y + 3.\] \[x = \frac{y + 3}{y - 2}\] \[\text{so}\] \[f^{-1}(x) = \frac{x + 3}{x - 2}.\]The excluded value \(x = 2\) in the codomain is exactly where this formula breaks down, which is why the codomain was \(\mathbb{R} - \{2\}\).
(b) Substitute:
\[f^{-1}(5) = \frac{5 + 3}{5 - 2} = \frac{8}{3}.\]Check by applying \(f\): \(f\!\left(\tfrac83\right) = \dfrac{\tfrac{16}{3} + 3}{\tfrac83 - 1} = \dfrac{\tfrac{25}{3}}{\tfrac{5}{3}} = 5\). (Equivalently, \(f^{-1}(5)\) is the solution of \(2x + 3 = 5(x - 1)\), i.e. \(3x = 8\).)
(a) \(f^{-1}(x) = \dfrac{x + 3}{x - 2}\); (b) \(f^{-1}(5) = \dfrac{8}{3}\)
Review:
15Let \(f(x) = x^2 + 1\) and \(g(x) = 2x - 3\) be functions from \(\mathbb{R}\) to \(\mathbb{R}\). (a) Find a simplified formula for \((f \circ g)(x)\). (b) Compute \((g \circ f)(2)\). (c) Compute \((f \circ f)(1)\).
Solution
Composition applies the right-hand function first: \((f \circ g)(x) = f(g(x))\).
(a) Substitute \(g(x)\) into \(f\):
\[(f \circ g)(x) = f(2x - 3) = (2x - 3)^2 + 1 = 4x^2 - 12x + 9 + 1 = 4x^2 - 12x + 10.\](b) First \(f(2) = 4 + 1 = 5\), then \(g(5) = 10 - 3 = 7\):
\[(g \circ f)(2) = g(f(2)) = g(5) = 7.\]Note that the order matters: \((g \circ f)(x) = 2(x^2 + 1) - 3 = 2x^2 - 1\), a different function from \((f \circ g)(x)\); at \(x = 2\) it gives \(7\), while \((f \circ g)(2) = 2\).
(c) \(f(1) = 2\), then \(f(2) = 5\):
\[(f \circ f)(1) = f(f(1)) = f(2) = 5.\](a) \(4x^2 - 12x + 10\); (b) \(7\); (c) \(5\)
Review:
16Evaluate (a) \(\left\lfloor -\tfrac{7}{2} \right\rfloor\) and (b) \(\left\lceil \tfrac{13}{4} \right\rceil\). (c) How many integers \(n\) satisfy \(\left\lceil \tfrac{n}{3} \right\rceil = 4\)?
Solution
The floor \(\lfloor x \rfloor\) is the largest integer \(\le x\); the ceiling \(\lceil x \rceil\) is the smallest integer \(\ge x\). On the number line, floor moves left (down) to an integer and ceiling moves right (up).
(a) \(-\tfrac72 = -3.5\) lies between \(-4\) and \(-3\). Moving down gives
\[\left\lfloor -\tfrac{7}{2} \right\rfloor = -4\]not \(-3\); the common slip is to drop the fractional part, which is rounding toward zero rather than down.
(b) \(\tfrac{13}{4} = 3.25\), and the smallest integer at or above it is
\[\left\lceil \tfrac{13}{4} \right\rceil = 4.\](c) Use the characterization \(\lceil x \rceil = m \iff m - 1 \lt x \le m\). With \(m = 4\):
\[3 \lt \frac{n}{3} \le 4\] \[\Longrightarrow\ 9 \lt n \le 12\]so \(n \in \{10, 11, 12\}\): three integers. (Check: \(\lceil 9/3 \rceil = 3\), while \(\lceil 10/3 \rceil = \lceil 11/3 \rceil = \lceil 12/3 \rceil = 4\).)
(a) \(-4\); (b) \(4\); (c) \(3\) integers (\(n = 10, 11, 12\))
Review:
17Let \(A = \{1, 2, 3\}\) and \(B = \{a, b, c, d, e\}\). (a) How many functions are there from \(A\) to \(B\)? (b) How many of them are injective (one-to-one)? (c) How many bijections are there from \(\{1, 2, 3, 4\}\) to itself?
Solution
(a) A function from \(A\) to \(B\) assigns to each of the 3 elements of \(A\) one of the 5 elements of \(B\), with no other restriction. By the product rule,
\[5\cdot 5\cdot 5 = 5^{3} = 125.\]In general there are \(|B|^{|A|}\) functions from \(A\) to \(B\).
(b) An injective function may not reuse an output. Assign \(f(1)\) in 5 ways, \(f(2)\) in 4 remaining ways, \(f(3)\) in 3:
\[5\cdot 4\cdot 3 = 60 = P(5, 3).\]None of these can be surjective, since 3 inputs cannot cover 5 outputs.
(c) A bijection from a 4-element set to itself is a permutation of its elements: \(4\) choices for the image of \(1\), then \(3\), \(2\), \(1\):
\[4! = 24.\](a) \(125\); (b) \(60\); (c) \(24\)
Review: ·
18Let \(f(x) = x^2 + 4\). (a) On which domain below is \(f\) a bijection onto \([4, \infty)\)? (i) all of \(\mathbb{R}\); (ii) \([0, \infty)\); (iii) \([4, \infty)\); (iv) \([-2, 2]\). (b) With that domain, find a formula for \(f^{-1}(x)\). (c) Compute \(f^{-1}(20)\).
Solution
(a) On all of \(\mathbb{R}\), \(f(-x) = f(x)\), so \(f\) is not injective and has no inverse. Restricting to \(x \ge 0\) removes the mirror image: on \([0, \infty)\) the function is strictly increasing, hence injective, and its outputs run from \(f(0) = 4\) upward without gaps, so it is onto \([4, \infty)\). Choice (ii).
Choice (iii) is injective but misses the values in \([4, 20)\) (its smallest output is \(f(4) = 20\)), and (iv) is neither injective (\(f(-2) = f(2)\)) nor onto.
(b) Solve \(y = x^2 + 4\) for \(x \ge 0\):
\[x^2 = y - 4\] \[\Longrightarrow\ x = \sqrt{y - 4}\]taking the nonnegative root because the domain is \([0, \infty)\). Hence
\[f^{-1}(x) = \sqrt{x - 4}\] \[x \ge 4.\](c) \(f^{-1}(20) = \sqrt{20 - 4} = \sqrt{16} = 4\). Check: \(f(4) = 16 + 4 = 20\).
(a) (ii) \([0, \infty)\); (b) \(f^{-1}(x) = \sqrt{x - 4}\); (c) \(4\)
Review:
19Let \(f(x) = 2x + 1\) and \(g(x) = x^2\). (a) Find a simplified formula for \((g \circ f)(x)\). (b) Find all real \(x\) with \((g \circ f)(x) = 25\).
Solution
(a) \((g \circ f)(x) = g(f(x))\): square the output of \(f\).
\[(g \circ f)(x) = (2x + 1)^2 = 4x^2 + 4x + 1.\](For contrast, \((f \circ g)(x) = 2x^2 + 1\).)
(b) It is easiest to work with the unexpanded form:
\[(2x + 1)^2 = 25\] \[\Longrightarrow\ 2x + 1 = 5 \ \text{ or }\ 2x + 1 = -5.\] \[x = 2 \quad\text{or}\quad x = -3.\]Both must be kept, since squaring erases the sign. Check: \(f(2) = 5\), \(g(5) = 25\); \(f(-3) = -5\), \(g(-5) = 25\). The fact that two inputs give the same output shows \(g \circ f\) is not injective.
(a) \(4x^2 + 4x + 1\); (b) \(x = 2\) or \(x = -3\)
Review:
20A school is sending 1000 students on a trip in buses that hold 42 passengers each. (a) How many buses are needed? (b) If every bus except the last is filled, how many students ride on the last bus? (c) The students are given ID numbers in binary. How many bits are needed so that all 1000 students can receive distinct IDs?
Solution
(a) The number of buses is \(1000/42 \approx 23.8\) rounded up, because a partly filled bus is still a bus:
\[\left\lceil \frac{1000}{42} \right\rceil = 24.\]Check: \(23\cdot 42 = 966 \lt 1000\), while \(24\cdot 42 = 1008 \ge 1000\).
(b) The number of full buses is \(\lfloor 1000/42 \rfloor = 23\), carrying \(966\) students. The remainder ride on the last bus:
\[1000 - 23\cdot 42 = 1000 - 966 = 34.\]This is \(1000 \bmod 42\).
(c) With \(b\) bits there are \(2^b\) different strings, so we need the smallest \(b\) with \(2^b \ge 1000\), that is, \(b = \lceil \log_2 1000 \rceil\). Since \(2^9 = 512 \lt 1000 \le 1024 = 2^{10}\),
\[b = 10 \text{ bits}.\](a) \(24\) buses; (b) \(34\) students; (c) \(10\) bits
Review:
Set 2: proofs, induction and number theory
Discrete Math · Practice problems 21 to 40
Problems 21 to 40
One hundred problems modelled on a first discrete mathematics course. Every problem opens to a full, step-by-step solution with the final answer highlighted. Try it on paper first; the Review link at the end jumps back to the matching notes.
21Name the proof technique in each case. (a) To prove “if \(n^2\) is even, then \(n\) is even,” you assume \(n\) is odd and show that \(n^2\) is odd. (b) To prove that \(\sqrt{2}\) is irrational, you assume \(\sqrt{2} = a/b\) in lowest terms and derive that \(a\) and \(b\) are both even, which is impossible. (c) To prove that there is a prime between 10 and 20, you point out that 11 is prime.
Solution
(a) The statement is \(p \to q\) with \(p\): “\(n^2\) is even” and \(q\): “\(n\) is even.” Assuming \(\lnot q\) (\(n\) odd) and deriving \(\lnot p\) (\(n^2\) odd) proves the contrapositive \(\lnot q \to \lnot p\), which is equivalent to \(p \to q\). That is a proof by contraposition. The computation is \(n = 2k + 1 \Rightarrow n^2 = 4k^2 + 4k + 1 = 2(2k^2 + 2k) + 1\), odd.
(b) Here the statement itself (irrationality) is assumed false, and the assumption leads to something impossible (a fraction in lowest terms whose numerator and denominator share the factor 2). Deriving a falsehood from \(\lnot p\) proves \(p\): a proof by contradiction.
(c) The claim is \(\exists x\,P(x)\). Producing a specific witness, \(x = 11\), and checking it is a constructive existence proof. (A nonconstructive proof would show that some prime must exist in the range without naming one.)
(a) proof by contraposition; (b) proof by contradiction; (c) constructive existence proof
Review:
22Each inequality below holds for all sufficiently large \(n\) and is proved by induction, starting from the first \(n\) at which it is true. (a) Find the smallest integer \(n \ge 0\) for which \(n! \gt 3^n\). (b) Find the smallest integer \(n \ge 2\) for which \(2^n \gt n^3\).
Solution
The base case of such an induction is the first value where the inequality actually holds, so tabulate both sides until it does.
(a)
\[\begin{aligned} n = 5:&\quad 5! = 120,\ 3^5 = 243 \quad(\text{fails}) \\ n = 6:&\quad 6! = 720,\ 3^6 = 729 \quad(\text{fails, barely}) \\ n = 7:&\quad 7! = 5040,\ 3^7 = 2187 \quad(\text{holds}) \end{aligned}\]Smaller \(n\) fail as well (\(0! = 1 = 3^0\), \(1 \lt 3\), \(2 \lt 9\), \(6 \lt 27\), \(24 \lt 81\)), so the base case is \(n = 7\). Inductive step: if \(k! \gt 3^k\) with \(k \ge 7\), then \((k + 1)! = (k + 1)\,k! \gt (k + 1)\,3^k \ge 3\cdot 3^k = 3^{k + 1}\).
(b)
\[\begin{aligned} n = 8:&\quad 2^8 = 256,\ 8^3 = 512 \quad(\text{fails}) \\ n = 9:&\quad 2^9 = 512,\ 9^3 = 729 \quad(\text{fails}) \\ n = 10:&\quad 2^{10} = 1024,\ 10^3 = 1000 \quad(\text{holds}) \end{aligned}\]For \(2 \le n \le 7\) the cube is far larger (\(4 \lt 8\), \(8 \lt 27\), \(16 \lt 64\), \(32 \lt 125\), \(64 \lt 216\), \(128 \lt 343\)), so the smallest such \(n \ge 2\) is \(n = 10\). (The restriction \(n \ge 2\) matters: \(n = 1\) gives \(2 \gt 1\) trivially, but the inequality then fails from \(n = 2\) to \(n = 9\).)
(a) \(n = 7\); (b) \(n = 10\)
Review: ·
23Induction proves the formulas \(1 + 3 + 5 + \cdots + (2n - 1) = n^2\) and \(1\cdot 2 + 2\cdot 3 + \cdots + n(n + 1) = \dfrac{n(n + 1)(n + 2)}{3}\) for all \(n \ge 1\). Write out the inductive step for the second formula, then use the formulas to evaluate (a) the sum of the first 25 odd positive integers and (b) \(1\cdot 2 + 2\cdot 3 + \cdots + 10\cdot 11\).
Solution
Inductive step for the second formula. Assume \(1\cdot 2 + \cdots + k(k + 1) = \dfrac{k(k + 1)(k + 2)}{3}\). Adding the next term \((k + 1)(k + 2)\):
\[\frac{k(k + 1)(k + 2)}{3} + (k + 1)(k + 2) = (k + 1)(k + 2)\left(\frac{k}{3} + 1\right) = \frac{(k + 1)(k + 2)(k + 3)}{3}\]which is the formula with \(n = k + 1\). With the base case \(1\cdot 2 = 2 = \dfrac{1\cdot 2\cdot 3}{3}\), the formula holds for all \(n \ge 1\).
(a) The first 25 odd positive integers are \(1, 3, \dots, 49\) (the 25th is \(2\cdot 25 - 1 = 49\)), and the first formula with \(n = 25\) gives
\[1 + 3 + \cdots + 49 = 25^2 = 625.\](b) The second formula with \(n = 10\):
\[1\cdot 2 + 2\cdot 3 + \cdots + 10\cdot 11 = \frac{10\cdot 11\cdot 12}{3} = \frac{1320}{3} = 440.\](a) \(625\); (b) \(440\)
Review:
24The following identities are standard induction exercises: \(\displaystyle\sum_{k=1}^{n} k^2 = \frac{n(n + 1)(2n + 1)}{6}\), \(\displaystyle\sum_{k=1}^{n} k^3 = \left(\frac{n(n + 1)}{2}\right)^{2}\) and \(\displaystyle\sum_{k=0}^{n} 2^k = 2^{n + 1} - 1\). Use them to evaluate (a) \(1^2 + 2^2 + \cdots + 12^2\); (b) \(1^3 + 2^3 + \cdots + 8^3\); (c) \(1 + 2 + 4 + \cdots + 2^{10}\).
Solution
(a) With \(n = 12\):
\[\sum_{k=1}^{12} k^2 = \frac{12\cdot 13\cdot 25}{6} = \frac{3900}{6} = 650.\](b) With \(n = 8\), the sum of cubes is the square of the triangular number \(1 + 2 + \cdots + 8 = 36\):
\[\sum_{k=1}^{8} k^3 = \left(\frac{8\cdot 9}{2}\right)^2 = 36^2 = 1296.\](c) The sum runs from \(2^0\) to \(2^{10}\), so \(n = 10\):
\[1 + 2 + \cdots + 2^{10} = 2^{11} - 1 = 2048 - 1 = 2047.\]A quick check of the inductive step for (c): adding \(2^{n+1}\) to \(2^{n+1} - 1\) gives \(2\cdot 2^{n+1} - 1 = 2^{n+2} - 1\), the formula for \(n + 1\). Watch the off-by-one trap: the answer is \(2^{11} - 1\), not \(2^{10} - 1 = 1023\).
(a) \(650\); (b) \(1296\); (c) \(2047\)
Review:
25(a) Induction shows that \(7^n - 1\) is divisible by 6 for every integer \(n \ge 0\). Write out the inductive step, then compute the quotient \(\dfrac{7^5 - 1}{6}\). (b) It is also true that \(n^3 - n\) is divisible by 6 for every integer \(n\). Compute \(\dfrac{n^3 - n}{6}\) for \(n = 10\).
Solution
(a) Base case: \(7^0 - 1 = 0 = 6\cdot 0\). Inductive step: suppose \(6 \mid 7^k - 1\), say \(7^k - 1 = 6m\). Then
\[7^{k+1} - 1 = 7\cdot 7^k - 1 = 7(7^k - 1) + 6 = 7\cdot 6m + 6 = 6(7m + 1)\]which is divisible by 6. Now the quotient at \(n = 5\): \(7^5 = 16807\), so
\[\frac{7^5 - 1}{6} = \frac{16806}{6} = 2801.\](A direct reason the division is exact: \(7^5 - 1 = (7 - 1)(7^4 + 7^3 + 7^2 + 7 + 1)\), and the second factor is \(2401 + 343 + 49 + 7 + 1 = 2801\).)
(b) Factor: \(n^3 - n = n(n^2 - 1) = (n - 1)\,n\,(n + 1)\), a product of three consecutive integers. Among any three consecutive integers one is a multiple of 3 and at least one is even, so the product is divisible by \(2\cdot 3 = 6\). At \(n = 10\):
\[\frac{10^3 - 10}{6} = \frac{9\cdot 10\cdot 11}{6} = \frac{990}{6} = 165.\](a) \(2801\); (b) \(165\)
Review: ·
26The expression \(n^2 + n + 41\) is prime for \(n = 0, 1, 2, \dots\) for a surprisingly long run, which might tempt someone to conjecture that it is prime for every integer \(n \ge 0\). (a) Find the smallest positive integer \(n\) that is a counterexample. (b) What is the value of \(n^2 + n + 41\) at that \(n\), and how does it factor?
Solution
A single counterexample disproves a universal claim, so we look for an \(n\) that makes the expression composite. Rather than testing values one at a time, notice the algebraic structure:
\[n^2 + n + 41 = n(n + 1) + 41.\]If \(41\) divides \(n(n + 1)\), then \(41\) divides the whole expression, and the expression is larger than 41, so it is composite. The first positive \(n\) with \(41 \mid n(n + 1)\) is \(n = 40\) (then \(n + 1 = 41\)); for \(n = 1, \dots, 39\) neither \(n\) nor \(n + 1\) is a multiple of the prime 41.
This does not by itself rule out a composite value with some other prime factor for \(n \lt 40\), but checking shows every value for \(n = 0, \dots, 39\) is in fact prime (\(41, 43, 47, 53, 61, 71, \dots, 1601\)). So the smallest counterexample is
\[n = 40.\](b) At \(n = 40\):
\[40^2 + 40 + 41 = 1600 + 40 + 41 = 1681 = 41\cdot 41 = 41^2.\]Equivalently \(40\cdot 41 + 41 = 41(40 + 1) = 41^2\). The next value, \(n = 41\), is composite too: \(41\cdot 43\).
(a) \(n = 40\); (b) \(1681 = 41^2\)
Review: ·
27Use the Euclidean algorithm to find \(\gcd(1260, 756)\). Then find (a) the gcd, (b) \(\operatorname{lcm}(1260, 756)\), and (c) the number of division steps the algorithm took.
Solution
Each step divides the previous divisor by the previous remainder; the last nonzero remainder is the gcd.
\[1260 = 1\cdot 756 + 504\] \[756 = 1\cdot 504 + 252\] \[504 = 2\cdot 252 + 0\](a) The last nonzero remainder is \(252\), so \(\gcd(1260, 756) = 252\). (Check with factorizations: \(1260 = 2^2\cdot 3^2\cdot 5\cdot 7\) and \(756 = 2^2\cdot 3^3\cdot 7\); the common part is \(2^2\cdot 3^2\cdot 7 = 252\).)
(b) For positive integers \(\gcd(a, b)\cdot\operatorname{lcm}(a, b) = ab\), so
\[\operatorname{lcm}(1260, 756) = \frac{1260\cdot 756}{252} = 5\cdot 756 = 3780.\](c) Three divisions were performed (the third produced remainder 0 and ended the algorithm).
(a) \(252\); (b) \(3780\); (c) \(3\) steps
Review:
28(a) Compute \(\gcd(97, 35)\) with the Euclidean algorithm. (b) Work the algorithm backwards to write \(\gcd(97, 35) = 97s + 35t\) (Bézout’s identity) with integers \(s, t\), where \(0 \le s \lt 35\). Give \(s\). (c) Give the matching \(t\).
Solution
(a) Forward pass:
\[97 = 2\cdot 35 + 27,\quad 35 = 1\cdot 27 + 8,\quad 27 = 3\cdot 8 + 3,\quad 8 = 2\cdot 3 + 2,\quad 3 = 1\cdot 2 + 1,\quad 2 = 2\cdot 1 + 0.\]The last nonzero remainder is 1, so \(\gcd(97, 35) = 1\): the numbers are relatively prime.
(b), (c) Back-substitute, always expressing 1 as a combination of the two most recent numbers:
\[1 = 3 - 1\cdot 2 = 3 - (8 - 2\cdot 3) = 3\cdot 3 - 8\] \[= 3(27 - 3\cdot 8) - 8 = 3\cdot 27 - 10\cdot 8 = 3\cdot 27 - 10(35 - 27) = 13\cdot 27 - 10\cdot 35\] \[= 13(97 - 2\cdot 35) - 10\cdot 35 = 13\cdot 97 - 36\cdot 35.\]So \(s = 13\) and \(t = -36\). Check: \(13\cdot 97 = 1261\) and \(36\cdot 35 = 1260\), and \(1261 - 1260 = 1\).
Bézout coefficients are not unique: \((s, t) = (13 + 35k,\ -36 - 97k)\) works for every integer \(k\). The condition \(0 \le s \lt 35\) picks out \(k = 0\). A useful consequence: \(-36 \equiv 61 \pmod{97}\) is the inverse of 35 modulo 97.
(a) \(1\); (b) \(s = 13\); (c) \(t = -36\), since \(13\cdot 97 - 36\cdot 35 = 1\)
Review:
29Compute (a) \(2^{100} \bmod 7\); (b) \(3^{50} \bmod 11\); (c) \((123\cdot 456 + 789) \bmod 10\).
Solution
Never compute the big power. Reduce modulo the modulus at every step, and look for a small power that is congruent to 1.
(a) \(2^3 = 8 \equiv 1 \pmod 7\). Write \(100 = 3\cdot 33 + 1\):
\[2^{100} = (2^3)^{33}\cdot 2 \equiv 1^{33}\cdot 2 = 2 \pmod 7.\](b) \(3^5 = 243 = 22\cdot 11 + 1\), so \(3^5 \equiv 1 \pmod{11}\). Since \(50 = 5\cdot 10\),
\[3^{50} = (3^5)^{10} \equiv 1^{10} = 1 \pmod{11}.\](Fermat’s little theorem gives \(3^{10} \equiv 1\) directly, which also finishes it.)
(c) Modulo 10 only the last digits matter: \(123 \equiv 3\), \(456 \equiv 6\), \(789 \equiv 9\).
\[123\cdot 456 + 789 \equiv 3\cdot 6 + 9 = 27 \equiv 7 \pmod{10}.\]Check: \(123\cdot 456 + 789 = 56088 + 789 = 56877\), whose last digit is 7.
(a) \(2\); (b) \(1\); (c) \(7\)
Review:
30(a) Find the inverse of \(17\) modulo \(43\), i.e. the integer \(x\) with \(0 \le x \lt 43\) and \(17x \equiv 1 \pmod{43}\). (b) Use it to solve the congruence \(17x \equiv 5 \pmod{43}\), giving the solution with \(0 \le x \lt 43\).
Solution
(a) Since 43 is prime and \(17 \lt 43\), \(\gcd(17, 43) = 1\) and the inverse exists. Euclid forward:
\[43 = 2\cdot 17 + 9\] \[17 = 1\cdot 9 + 8\] \[9 = 1\cdot 8 + 1.\]Backwards:
\[1 = 9 - 8 = 9 - (17 - 9) = 2\cdot 9 - 17 = 2(43 - 2\cdot 17) - 17 = 2\cdot 43 - 5\cdot 17.\]So \(17\cdot(-5) \equiv 1 \pmod{43}\), and the inverse in the range \(0\) to \(42\) is \(-5 + 43 = 38\). Check: \(17\cdot 38 = 646 = 15\cdot 43 + 1\).
(b) Multiply both sides of \(17x \equiv 5\) by the inverse \(38\):
\[x \equiv 38\cdot 5 = 190 \equiv 190 - 4\cdot 43 = 190 - 172 = 18 \pmod{43}.\]Check: \(17\cdot 18 = 306 = 7\cdot 43 + 5\), so \(17\cdot 18 \equiv 5\). The solution is unique modulo 43 because 17 is invertible.
(a) \(38\); (b) \(x \equiv 18 \pmod{43}\)
Review:
31Solve the system \(x \equiv 3 \pmod 4\), \(x \equiv 1 \pmod 5\), \(x \equiv 6 \pmod 7\). (a) Give the smallest positive solution. (b) The solutions form one residue class modulo what number? (c) Give the second-smallest positive solution.
Solution
The moduli 4, 5, 7 are pairwise relatively prime, so the Chinese remainder theorem promises a unique solution modulo \(M = 4\cdot 5\cdot 7 = 140\).
Set \(M_1 = 140/4 = 35\), \(M_2 = 140/5 = 28\), \(M_3 = 140/7 = 20\), and find the inverse \(y_i\) of each \(M_i\) modulo its own \(m_i\):
\[35 \equiv 3 \pmod 4,\ 3\cdot 3 = 9 \equiv 1 \Rightarrow y_1 = 3\] \[28 \equiv 3 \pmod 5,\ 3\cdot 2 = 6 \equiv 1 \Rightarrow y_2 = 2\] \[20 \equiv 6 \pmod 7,\ 6\cdot 6 = 36 \equiv 1 \Rightarrow y_3 = 6.\]Then \(x = a_1 M_1 y_1 + a_2 M_2 y_2 + a_3 M_3 y_3\) with \(a = (3, 1, 6)\):
\[x = 3\cdot 35\cdot 3 + 1\cdot 28\cdot 2 + 6\cdot 20\cdot 6 = 315 + 56 + 720 = 1091.\](a) Reduce: \(1091 - 7\cdot 140 = 1091 - 980 = 111\). Check: \(111 = 27\cdot 4 + 3\), \(111 = 22\cdot 5 + 1\), \(111 = 15\cdot 7 + 6\). The smallest positive solution is \(111\).
(b) All solutions are \(x \equiv 111 \pmod{140}\), so the modulus is \(140\).
(c) The next one is \(111 + 140 = 251\).
(a) \(111\); (b) \(140\); (c) \(251\)
Review:
32Today is Tuesday and the time is 9:00 in the morning. (a) Compute \(1000 \bmod 7\). (b) What day of the week will it be 1000 days from today? (c) What hour will a 24-hour clock show 500 hours from now? (Give the hour as a number from 0 to 23.)
Solution
Days of the week repeat every 7 days and clock hours every 24, so both questions are modular arithmetic.
(a) \(7\cdot 142 = 994\), so
\[1000 = 142\cdot 7 + 6\] \[1000 \bmod 7 = 6.\](b) 994 days from now is again a Tuesday (a whole number of weeks). Six more days: Wednesday, Thursday, Friday, Saturday, Sunday, Monday. So 1000 days from today is a Monday. (Equivalently, 6 days ahead is 1 day back.)
(c) \(500 = 20\cdot 24 + 20\), so 500 hours is 20 full days plus 20 hours. Twenty hours after 9:00 is
\[(9 + 20) \bmod 24 = 29 \bmod 24 = 5\]i.e. 5:00 in the morning, written as hour \(5\) on a 24-hour clock.
(a) \(6\); (b) Monday; (c) hour \(5\) (5:00 am)
Review:
33Find the prime factorization of \(5460\). Then give (a) the number of distinct prime factors; (b) the number of positive divisors of 5460; (c) its largest prime factor.
Solution
Divide out small primes in turn:
\[5460 = 2\cdot 2730 = 2^2\cdot 1365 = 2^2\cdot 3\cdot 455 = 2^2\cdot 3\cdot 5\cdot 91 = 2^2\cdot 3\cdot 5\cdot 7\cdot 13.\](Divisibility checks: 5460 ends in 0, so 2 and 5 divide it; the digit sum \(5 + 4 + 6 + 0 = 15\) is a multiple of 3; and \(91 = 7\cdot 13\).)
(a) The distinct primes are \(2, 3, 5, 7, 13\): five of them.
(b) A divisor is formed by choosing an exponent for each prime from 0 up to its exponent in the factorization. With exponents \(2, 1, 1, 1, 1\) the count is
\[(2 + 1)(1 + 1)(1 + 1)(1 + 1)(1 + 1) = 3\cdot 2^4 = 48.\](c) The largest prime factor is \(13\).
\(5460 = 2^2\cdot 3\cdot 5\cdot 7\cdot 13\); (a) \(5\); (b) \(48\); (c) \(13\)
Review:
34(a) To decide by trial division whether \(1013\) is prime, what is the largest prime you need to test as a divisor? (b) Is 1013 prime or composite? (c) How many primes are less than 32?
Solution
(a) If \(n\) is composite, it has a prime factor \(p \le \sqrt{n}\) (if \(n = ab\) with both factors above \(\sqrt n\), the product would exceed \(n\)). Since \(31^2 = 961 \le 1013 \lt 1024 = 32^2\), we have \(\lfloor\sqrt{1013}\rfloor = 31\), and the largest prime to test is
\[31.\](b) Test the primes up to 31. The number is odd; its digit sum \(1 + 0 + 1 + 3 = 5\) is not a multiple of 3; it does not end in 0 or 5. Then
\[1013 = 7\cdot 144 + 5 = 11\cdot 92 + 1 = 13\cdot 77 + 12 = 17\cdot 59 + 10 = 19\cdot 53 + 6 = 23\cdot 44 + 1 = 29\cdot 34 + 27\] \[= 31\cdot 32 + 21.\]No remainder is zero, so \(1013\) is prime.
(c) The primes below 32 are \(2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31\): eleven primes, which is exactly the list of trial divisors used in (b).
(a) \(31\); (b) prime; (c) \(11\)
Review:
35Let \(a = 2^3\cdot 3^2\cdot 5\) and \(b = 2^2\cdot 3\cdot 7^2\). Using the prime factorizations, find (a) \(\gcd(a, b)\) and (b) \(\operatorname{lcm}(a, b)\). Then verify that \(\gcd(a, b)\cdot\operatorname{lcm}(a, b) = ab\).
Solution
Line up the primes with exponent 0 where a prime is missing: \(a = 2^3\cdot 3^2\cdot 5^1\cdot 7^0\) and \(b = 2^2\cdot 3^1\cdot 5^0\cdot 7^2\). The gcd takes the smaller exponent of each prime, the lcm the larger.
(a)
\[\gcd(a, b) = 2^{\min(3,2)}\cdot 3^{\min(2,1)}\cdot 5^{\min(1,0)}\cdot 7^{\min(0,2)} = 2^2\cdot 3 = 12.\](b)
\[\operatorname{lcm}(a, b) = 2^{3}\cdot 3^{2}\cdot 5\cdot 7^{2} = 8\cdot 9\cdot 5\cdot 49 = 17640.\]Verification. \(a = 8\cdot 9\cdot 5 = 360\) and \(b = 4\cdot 3\cdot 49 = 588\), so \(ab = 360\cdot 588 = 211680\). And \(12\cdot 17640 = 211680\). They agree, as they must: for each prime, \(\min + \max\) of the two exponents equals their sum.
(a) \(12\); (b) \(17640\)
Review:
36Convert the decimal number \(2026\) to (a) binary, (b) octal (base 8) and (c) hexadecimal (base 16).
Solution
(a) Divide repeatedly by 2 and record the remainders; the binary digits are the remainders read from last to first.
\[2026 = 2\cdot 1013 + 0,\ 1013 = 2\cdot 506 + 1,\ 506 = 2\cdot 253 + 0,\ 253 = 2\cdot 126 + 1,\ 126 = 2\cdot 63 + 0,\ 63 = 2\cdot 31 + 1\] \[31 = 2\cdot 15 + 1,\ 15 = 2\cdot 7 + 1,\ 7 = 2\cdot 3 + 1,\ 3 = 2\cdot 1 + 1,\ 1 = 2\cdot 0 + 1.\]Reading upward: \(2026 = 11111101010_2\). Check: \(1024 + 512 + 256 + 128 + 64 + 32 + 8 + 2 = 2026\).
(b) Group the binary digits in threes from the right, padding on the left: \(011\ 111\ 101\ 010\), which is \(3, 7, 5, 2\):
\[2026 = 3752_8.\]Check: \(3\cdot 512 + 7\cdot 64 + 5\cdot 8 + 2 = 1536 + 448 + 40 + 2 = 2026\).
(c) Group in fours: \(0111\ 1110\ 1010\), which is \(7, 14, 10\), and in hexadecimal \(14 = \mathrm{E}\), \(10 = \mathrm{A}\):
\[2026 = 7\mathrm{EA}_{16}.\]Check: \(7\cdot 256 + 14\cdot 16 + 10 = 1792 + 224 + 10 = 2026\).
(a) \(11111101010_2\); (b) \(3752_8\); (c) \(7\mathrm{EA}_{16}\)
Review:
37(a) Convert \(1011011_2\) to decimal. (b) Convert \(2\mathrm{F}3_{16}\) to decimal. (c) Add the binary numbers \(1101_2 + 1011_2\) and give the sum in binary.
Solution
(a) Expand in powers of 2, from the right: the digits are \(1, 1, 0, 1, 1, 0, 1\) at positions \(2^0\) through \(2^6\).
\[1011011_2 = 64 + 0 + 16 + 8 + 0 + 2 + 1 = 91.\](b) In hexadecimal \(\mathrm{F} = 15\). Expand in powers of 16:
\[2\mathrm{F}3_{16} = 2\cdot 256 + 15\cdot 16 + 3 = 512 + 240 + 3 = 755.\](c) Add column by column from the right, carrying when a column reaches 2: \(1 + 1 = 10_2\) (write 0, carry 1); \(0 + 1 + 1 = 10_2\) (write 0, carry 1); \(1 + 0 + 1 = 10_2\) (write 0, carry 1); \(1 + 1 + 1 = 11_2\) (write 1, carry 1); the final carry gives a leading 1.
\[1101_2 + 1011_2 = 11000_2.\]Check in decimal: \(13 + 11 = 24 = 16 + 8 = 11000_2\).
(a) \(91\); (b) \(755\); (c) \(11000_2\)
Review:
38(a) Write \(-137 = 11q + r\) with integers \(q\) and \(r\) and \(0 \le r \lt 11\) (the division algorithm). Give \(q\). (b) Give \(r\). (c) Compute \(2026 \bmod 9\) without long division, using the digit sum.
Solution
(a), (b) Start with the positive number: \(137 = 12\cdot 11 + 5\). Negating gives \(-137 = -12\cdot 11 - 5\), but the remainder must be nonnegative. Borrow one more multiple of 11:
\[-137 = -13\cdot 11 + 6\] \[\text{since } -13\cdot 11 = -143 \text{ and } -137 - (-143) = 6.\]So \(q = -13\) and \(r = 6\). The common mistake is \(q = -12\), \(r = -5\), which violates \(0 \le r \lt 11\); the quotient is \(\lfloor -137/11 \rfloor = \lfloor -12.45\ldots \rfloor = -13\), rounding down, not toward zero.
(c) Because \(10 \equiv 1 \pmod 9\), every power of 10 is \(\equiv 1\), so a number is congruent to its digit sum modulo 9:
\[2026 \equiv 2 + 0 + 2 + 6 = 10 \equiv 1 \pmod 9.\]Check: \(9\cdot 225 = 2025\), so \(2026 = 225\cdot 9 + 1\).
(a) \(q = -13\); (b) \(r = 6\); (c) \(1\)
Review:
39A post office sells only 4-cent and 7-cent stamps. Strong induction shows that every amount of postage of 18 cents or more can be formed. (a) What is the largest amount of postage that cannot be formed? (b) How many positive amounts cannot be formed?
Solution
An amount \(n\) can be formed exactly when \(n = 4i + 7j\) for some nonnegative integers \(i, j\). List the small amounts: the ones that can be formed are
\[4, 7, 8, 11, 12, 14, 15, 16, 18, 19, 20, 21, \dots\](\(18 = 4 + 7 + 7\), \(19 = 4 + 4 + 4 + 7\), \(20 = 4\cdot 5\), \(21 = 7\cdot 3\)), and the ones that cannot are
\[1, 2, 3, 5, 6, 9, 10, 13, 17.\]Why nothing above 17 is missing: the four consecutive amounts \(18, 19, 20, 21\) are all formable, and if every amount from 18 up to \(k\) (with \(k \ge 21\)) is formable, then \(k + 1 - 4 \ge 18\) is formable and adding one 4-cent stamp forms \(k + 1\). That is the strong induction, with the four base cases \(18\) to \(21\).
(a) The largest amount that cannot be formed is \(17\). (For relatively prime denominations \(a, b\) the general formula is \(ab - a - b = 28 - 11 = 17\).)
(b) Counting the list: nine positive amounts cannot be formed. (The general count is \(\tfrac{(a - 1)(b - 1)}{2} = \tfrac{3\cdot 6}{2} = 9\).)
(a) \(17\) cents; (b) \(9\) amounts (\(1, 2, 3, 5, 6, 9, 10, 13, 17\))
Review: ·
40Use a proof by cases on the residue of \(n\) modulo 5. (a) For which residues \(r \in \{0, 1, 2, 3, 4\}\) is \(r^2 + 1\) divisible by 5? Give the set. (b) How many integers \(n\) with \(1 \le n \le 50\) have \(n^2 + 1\) divisible by 5?
Solution
Every integer is congruent to exactly one of \(0, 1, 2, 3, 4\) modulo 5, and \(n \equiv r\) implies \(n^2 + 1 \equiv r^2 + 1 \pmod 5\). So five cases settle every integer at once.
(a)
\[r = 0:\ 1\] \[r = 1:\ 2\] \[r = 2:\ 5 \equiv 0\] \[r = 3:\ 10 \equiv 0\] \[r = 4:\ 17 \equiv 2 \pmod 5.\]Hence \(5 \mid n^2 + 1\) exactly when \(n \equiv 2\) or \(n \equiv 3 \pmod 5\): the set of residues is \(\{2, 3\}\). (As a bonus, the case analysis proves that \(n^2 + 1\) is never divisible by 5 when \(n \equiv 0, 1, 4\).)
(b) The integers from 1 to 50 split evenly into the five residue classes, 10 in each. Two classes qualify:
\[2\cdot 10 = 20.\]Spot check: \(n = 2, 3, 7, 8, 12, 13, \dots\) give \(5, 10, 50, 65, 145, 170, \dots\), all multiples of 5.
(a) \(\{2, 3\}\); (b) \(20\)
Review: ·
Set 3: counting, binomial coefficients and probability
Discrete Math · Practice problems 41 to 65
Problems 41 to 65
One hundred problems modelled on a first discrete mathematics course. Every problem opens to a full, step-by-step solution with the final answer highlighted. Try it on paper first; the Review link at the end jumps back to the matching notes.
41A license plate consists of 3 uppercase letters followed by 3 digits. (a) How many different plates are possible? (b) How many are possible if no letter may be repeated and no digit may be repeated?
Solution
(a) By the product rule, the six positions are filled independently: 26 choices for each letter and 10 for each digit.
\[26^3\cdot 10^3 = 17576\cdot 1000 = 17{,}576{,}000.\](b) Without repetition the choices shrink: 26, then 25, then 24 for the letters (a permutation \(P(26, 3)\)), and 10, 9, 8 for the digits (\(P(10, 3)\)).
\[26\cdot 25\cdot 24\cdot 10\cdot 9\cdot 8 = 15600\cdot 720 = 11{,}232{,}000.\]The restriction removes about 36% of the plates. Note that letters and digits are restricted separately: a letter may not repeat a letter, but there is no rule linking the two blocks.
(a) \(17{,}576{,}000\); (b) \(11{,}232{,}000\)
Review:
42(a) How many distinguishable arrangements are there of the letters of the word SUCCESS? (b) How many of them have the three S’s next to each other?
Solution
(a) SUCCESS has 7 letters: S three times, C twice, U once, E once. If the letters were all different there would be \(7!\) arrangements; swapping identical letters does not create a new word, so divide by \(3!\) for the S’s and \(2!\) for the C’s:
\[\frac{7!}{3!\,2!} = \frac{5040}{12} = 420.\](b) Glue the three S’s into a single block SSS. Now we arrange 5 objects: the block, U, C, C, E, with the two C’s identical:
\[\frac{5!}{2!} = \frac{120}{2} = 60.\]No factor is needed for the inside of the block, since the S’s are indistinguishable. So 60 of the 420 arrangements, one in seven, keep the S’s together.
(a) \(420\); (b) \(60\)
Review:
43A committee of 4 is chosen from a club of 10 members. (a) How many committees are possible? (b) How many committees include the club president? (c) How many committees include at least one of the two co-founders, Ava and Ben?
Solution
Order does not matter on a committee, so these are combinations.
(a)
\[\binom{10}{4} = \frac{10\cdot 9\cdot 8\cdot 7}{4\cdot 3\cdot 2\cdot 1} = \frac{5040}{24} = 210.\](b) Put the president on the committee, then choose the other 3 members from the remaining 9:
\[\binom{9}{3} = \frac{9\cdot 8\cdot 7}{6} = 84.\](c) “At least one” is easiest by complement: count the committees with neither Ava nor Ben, which choose all 4 members from the other 8 people, and subtract.
\[\binom{10}{4} - \binom{8}{4} = 210 - 70 = 140.\]Direct check: exactly one of them, \(2\cdot\binom{8}{3} = 112\); both, \(\binom{8}{2} = 28\); total \(112 + 28 = 140\).
(a) \(210\); (b) \(84\); (c) \(140\)
Review: ·
44Six people, including Ana and Bo, line up in a row for a photo. (a) In how many ways can they line up if Ana and Bo must stand next to each other? (b) In how many ways if Ana and Bo must not stand next to each other? (c) In how many ways if Ana and Bo must occupy the two ends of the row?
Solution
With no restriction there are \(6! = 720\) lineups.
(a) Glue Ana and Bo into one block. Then 5 objects (the block and 4 other people) are arranged in \(5!\) ways, and the block can be Ana–Bo or Bo–Ana:
\[2\cdot 5! = 2\cdot 120 = 240.\](b) “Not adjacent” is the complement of “adjacent”:
\[720 - 240 = 480.\](c) Choose which of the two takes the left end (2 ways; the other takes the right end), then arrange the remaining 4 people in the 4 middle spots:
\[2\cdot 4! = 2\cdot 24 = 48.\](a) \(240\); (b) \(480\); (c) \(48\)
Review:
45Use the pigeonhole principle. (a) What is the smallest number of people that guarantees at least two share a birth month? (b) What is the smallest number of people that guarantees at least four share a birth month? (c) How many cards must be drawn from a standard 52-card deck to guarantee at least three cards of the same suit?
Solution
The generalized pigeonhole principle: if \(N\) objects are placed in \(k\) boxes, some box holds at least \(\lceil N/k \rceil\) objects. To guarantee a box with \(m\) objects, the worst case is that every box has \(m - 1\), and one more object forces \(m\): the answer is \(k(m - 1) + 1\).
(a) 12 months, want 2 in one month:
\[12\cdot 1 + 1 = 13.\]With 12 people every month could be used once; the 13th must repeat a month.
(b) 12 months, want 4 in one month: in the worst case each month has 3 people, which uses 36 people, and the next one makes four.
\[12\cdot 3 + 1 = 37.\](c) 4 suits, want 3 of one suit: the worst case is 2 cards of each suit, 8 cards, and the 9th card gives a third of some suit.
\[4\cdot 2 + 1 = 9.\](a) \(13\); (b) \(37\); (c) \(9\)
Review:
46(a) Compute \(\dbinom{12}{5}\). (b) Evaluate \(\displaystyle\sum_{k=0}^{12}\binom{12}{k}\). (c) How many subsets of a 12-element set have an even number of elements?
Solution
(a) Cancel before multiplying:
\[\binom{12}{5} = \frac{12\cdot 11\cdot 10\cdot 9\cdot 8}{5\cdot 4\cdot 3\cdot 2\cdot 1} = \frac{95040}{120} = 792.\](By symmetry \(\binom{12}{7} = 792\) as well.)
(b) The binomial theorem with \(x = y = 1\) gives \((1 + 1)^{12} = \sum_k \binom{12}{k}\), so
\[\sum_{k=0}^{12}\binom{12}{k} = 2^{12} = 4096.\]Combinatorially, this counts all subsets of a 12-element set, grouped by size.
(c) Put \(x = 1\), \(y = -1\) in the binomial theorem: \(0 = (1 - 1)^{12} = \sum_k \binom{12}{k}(-1)^k\), so the even-size subsets and the odd-size subsets are equally numerous. Each kind therefore accounts for half of the \(4096\) subsets:
\[\binom{12}{0} + \binom{12}{2} + \cdots + \binom{12}{12} = 2^{11} = 2048.\](a) \(792\); (b) \(4096\); (c) \(2048\)
Review:
47(a) Find the coefficient of \(x^5\) in the expansion of \((2x - 3)^8\). (b) Find the constant term in the expansion of \(\left(x + \dfrac{2}{x}\right)^{6}\).
Solution
(a) By the binomial theorem the general term of \((2x - 3)^8\) is \(\binom{8}{k}(2x)^k(-3)^{8-k}\). The power \(x^5\) comes from \(k = 5\):
\[\binom{8}{5}\,2^5\,(-3)^3 = 56\cdot 32\cdot(-27).\] \[56\cdot 32 = 1792\] \[1792\cdot 27 = 48384\] \[\text{so the coefficient is } -48384.\]The sign comes from the odd power of \(-3\); forgetting it, or forgetting the \(2^5\) from \((2x)^5\), are the usual errors.
(b) The general term is \(\binom{6}{k}x^{6-k}\left(\dfrac{2}{x}\right)^{k} = \binom{6}{k}2^k x^{6-2k}\). The constant term has exponent zero, so \(6 - 2k = 0\), \(k = 3\):
\[\binom{6}{3}2^3 = 20\cdot 8 = 160.\](a) \(-48384\); (b) \(160\)
Review:
48Consider bit strings of length 8. (a) How many start with a 1 or end with the two bits 00? (b) How many contain exactly three 1s? (c) How many contain at least one 1?
Solution
There are \(2^8 = 256\) bit strings of length 8 in all.
(a) The two conditions overlap, so use inclusion–exclusion. Strings starting with 1: the other 7 bits are free, \(2^7 = 128\). Strings ending in 00: the other 6 bits are free, \(2^6 = 64\). Strings doing both: 5 free bits, \(2^5 = 32\).
\[128 + 64 - 32 = 160.\](b) Choose which 3 of the 8 positions hold the 1s:
\[\binom{8}{3} = 56.\](c) Only one string, \(00000000\), has no 1s. Subtract it:
\[2^8 - 1 = 255.\](a) \(160\); (b) \(56\); (c) \(255\)
Review: ·
49(a) A bakery sells 4 varieties of donut. In how many ways can a box of 12 donuts be chosen, if donuts of the same variety are indistinguishable and the order in the box does not matter? (b) How many solutions in nonnegative integers does \(x_1 + x_2 + x_3 = 10\) have?
Solution
Both are selections with repetition allowed (combinations with repetition). Choosing \(r\) objects from \(n\) types with repetition can be done in \(\binom{n + r - 1}{r} = \binom{n + r - 1}{n - 1}\) ways: picture \(r\) stars separated into \(n\) groups by \(n - 1\) bars.
(a) \(n = 4\) varieties, \(r = 12\) donuts: 12 stars and 3 bars, and we choose where the 3 bars go among the 15 symbols.
\[\binom{15}{3} = \frac{15\cdot 14\cdot 13}{6} = 455.\](b) A solution is a way of distributing 10 identical units among 3 variables: 10 stars and 2 bars.
\[\binom{12}{2} = \frac{12\cdot 11}{2} = 66.\]Quick check of the method on a tiny case: \(x_1 + x_2 = 2\) has \(\binom{3}{1} = 3\) solutions, namely \((0,2), (1,1), (2,0)\).
(a) \(455\); (b) \(66\)
Review:
50A department has 7 math majors and 5 computer science majors. (a) How many 5-person committees have exactly 3 math majors and 2 computer science majors? (b) How many 5-person committees have at least 3 math majors?
Solution
(a) Choose the math majors and the computer science majors separately, then multiply:
\[\binom{7}{3}\binom{5}{2} = 35\cdot 10 = 350.\](b) “At least 3 math majors” on a 5-person committee means 3, 4 or 5 math majors. These cases are disjoint, so add them (the sum rule), computing each with the product rule as in (a):
\[\binom{7}{3}\binom{5}{2} + \binom{7}{4}\binom{5}{1} + \binom{7}{5}\binom{5}{0} = 35\cdot 10 + 35\cdot 5 + 21\cdot 1 = 350 + 175 + 21 = 546.\]Sanity check: all 5-person committees number \(\binom{12}{5} = 792\), so \(546\) is a plausible majority, since math majors outnumber the others.
(a) \(350\); (b) \(546\)
Review: ·
51(a) How many solutions in nonnegative integers does \(x_1 + x_2 + x_3 + x_4 = 20\) have? (b) How many solutions does it have if every \(x_i \ge 2\)?
Solution
(a) A solution distributes 20 identical units among 4 variables. Picture 20 stars in a row with 3 bars inserted to split them into 4 groups; the number of stars in each group is the value of that variable. Any arrangement of 20 stars and 3 bars is a solution, so we count the ways to choose which 3 of the 23 positions hold bars:
\[\binom{23}{3} = \frac{23\cdot 22\cdot 21}{6} = 1771.\](b) Give each variable its required 2 units first. Writing \(x_i = y_i + 2\) with \(y_i \ge 0\), the equation becomes
\[(y_1 + 2) + (y_2 + 2) + (y_3 + 2) + (y_4 + 2) = 20\] \[\Longrightarrow\ y_1 + y_2 + y_3 + y_4 = 12.\]That is an ordinary stars-and-bars count with 12 stars and 3 bars:
\[\binom{15}{3} = \frac{15\cdot 14\cdot 13}{6} = 455.\]The substitution is the whole trick: a lower bound on each variable is removed by subtracting it from the total, and the count is then unrestricted again.
(a) \(1771\); (b) \(455\)
Review:
52A teacher hands out 15 identical gold stars to three students. (a) In how many ways can this be done if every student receives at least one star? (b) In how many ways can it be done if a student may receive no stars but no student may receive more than 7?
Solution
Let \(x_1 + x_2 + x_3 = 15\) count the stars each student gets.
(a) Each \(x_i \ge 1\). Hand out one star to each student first, leaving 12 stars to distribute freely: \(y_1 + y_2 + y_3 = 12\) with \(y_i \ge 0\), which by stars and bars has
\[\binom{12 + 2}{2} = \binom{14}{2} = 91 \text{ solutions}.\](Equivalently: place 2 bars in the 14 gaps between 15 stars in a row, \(\binom{14}{2}\) ways.)
(b) Now \(0 \le x_i \le 7\). Upper bounds are handled by inclusion–exclusion. Without the upper bound there are
\[\binom{15 + 2}{2} = \binom{17}{2} = 136 \text{ solutions}.\]Call a solution bad if some student gets 8 or more. If \(x_1 \ge 8\), substitute \(x_1 = z_1 + 8\): then \(z_1 + x_2 + x_3 = 7\), which has \(\binom{9}{2} = 36\) solutions. The same count holds for \(x_2 \ge 8\) and for \(x_3 \ge 8\), so the bad solutions number \(3\cdot 36 = 108\), provided no solution was counted twice. Two students cannot both get 8 or more, since \(8 + 8 = 16 \gt 15\), so there is no overlap to add back.
\[136 - 108 = 28.\](a) \(91\); (b) \(28\)
Review:
53(a) In how many ways can four letters be placed into four addressed envelopes so that no letter goes into its own envelope? (b) Five people check their hats and the hats are handed back at random. What is the probability that nobody gets their own hat? Give four decimals. (c) In how many of the \(120\) ways of handing back the five hats does exactly one person get their own hat?
Solution
A permutation with no fixed points is a derangement. By inclusion–exclusion the number of derangements of \(n\) objects is
\[D_n = n!\left(1 - \frac{1}{1!} + \frac{1}{2!} - \frac{1}{3!} + \cdots + \frac{(-1)^n}{n!}\right).\](a) With \(n = 4\):
\[D_4 = 24\left(1 - 1 + \tfrac12 - \tfrac16 + \tfrac1{24}\right) = 12 - 4 + 1 = 9.\](You can list them: the 9 derangements of \(1234\) are \(2143, 2341, 2413, 3142, 3412, 3421, 4123, 4312, 4321\).)
(b) With \(n = 5\):
\[D_5 = 120\left(\tfrac12 - \tfrac16 + \tfrac1{24} - \tfrac1{120}\right) = 60 - 20 + 5 - 1 = 44.\]All \(5! = 120\) ways of returning the hats are equally likely, so
\[P(\text{nobody gets their own hat}) = \frac{44}{120} = \frac{11}{30} \approx 0.3667.\](c) Choose the one lucky person (5 ways); the other four hats must then form a derangement of four objects (\(D_4 = 9\) ways):
\[5\cdot 9 = 45.\]Check: \(44\) ways with no match, \(45\) with exactly one, and the remaining \(120 - 89 = 31\) have two or more matches.
(a) \(9\); (b) \(\dfrac{11}{30} \approx 0.3667\); (c) \(45\)
Review: ·
54(a) Find the coefficient of \(x^3y^4\) in the expansion of \((x + 2y)^7\). (b) Use the binomial theorem to evaluate \(\displaystyle\sum_{k=0}^{8}\binom{8}{k}2^k\). (c) Evaluate \(\displaystyle\sum_{k=0}^{10}\binom{10}{k}(-2)^k\).
Solution
The binomial theorem says \((a + b)^n = \sum_{k=0}^{n}\binom{n}{k}a^{n-k}b^k\).
(a) With \(a = x\), \(b = 2y\) and \(n = 7\), the term containing \(y^4\) has \(k = 4\):
\[\binom{7}{4}x^{3}(2y)^4 = 35\cdot 16\,x^3y^4 = 560\,x^3y^4.\]The common slip is to forget that the \(2\) is raised to the fourth power along with \(y\).
(b) Read the sum as a binomial expansion with \(a = 1\) and \(b = 2\):
\[\sum_{k=0}^{8}\binom{8}{k}1^{8-k}2^k = (1 + 2)^8 = 3^8 = 6561.\](c) The same idea with \(a = 1\) and \(b = -2\):
\[\sum_{k=0}^{10}\binom{10}{k}(-2)^k = (1 - 2)^{10} = (-1)^{10} = 1.\]The large alternating terms (the \(k = 10\) term alone is \(1024\)) cancel almost completely; the binomial theorem sees that without any arithmetic.
(a) \(560\); (b) \(6561\); (c) \(1\)
Review:
55(a) Find the positive integer \(n\) with \(\dbinom{n}{2} = 190\). (b) Use Pascal’s identity to write \(\dbinom{14}{5} + \dbinom{14}{6}\) as a single binomial coefficient, and evaluate it. (c) In how many ways can 12 students be divided into three teams of 4, if the teams are named Red, Green and Blue?
Solution
(a) \(\binom{n}{2} = \dfrac{n(n-1)}{2}\), so we need \(n(n - 1) = 380\):
\[n^2 - n - 380 = 0\] \[\Longrightarrow\ (n - 20)(n + 19) = 0\] \[\Longrightarrow\ n = 20.\]Check: \(\binom{20}{2} = \dfrac{20\cdot 19}{2} = 190\).
(b) Pascal’s identity is \(\binom{n}{k-1} + \binom{n}{k} = \binom{n+1}{k}\). With \(n = 14\) and \(k = 6\):
\[\binom{14}{5} + \binom{14}{6} = \binom{15}{6} = \frac{15\cdot 14\cdot 13\cdot 12\cdot 11\cdot 10}{720} = \frac{3{,}603{,}600}{720} = 5005.\](Directly: \(\binom{14}{5} = 2002\) and \(\binom{14}{6} = 3003\), which do add to \(5005\).)
(c) Fill the teams one at a time. Choose Red’s 4 students from 12, then Green’s from the remaining 8, and Blue gets the last 4:
\[\binom{12}{4}\binom{8}{4}\binom{4}{4} = 495\cdot 70\cdot 1 = 34{,}650.\]This is the multinomial coefficient \(\dfrac{12!}{4!\,4!\,4!}\). If the teams were unlabelled, the answer would be divided by \(3! = 6\), giving \(5775\).
(a) \(n = 20\); (b) \(\dbinom{15}{6} = 5005\); (c) \(34{,}650\)
Review: ·
56A robot moves on a grid from \((0, 0)\) to \((6, 6)\) using only unit steps to the right (R) and up (U). (a) How many different paths are there? (b) How many of the paths pass through the point \((2, 3)\)? (c) How many paths avoid \((2, 3)\)?
Solution
(a) Every path is a sequence of 12 steps, exactly 6 of them R and 6 of them U, in some order. A path is determined by choosing which 6 of the 12 positions are the R steps:
\[\binom{12}{6} = 924.\](b) Break the path at \((2, 3)\). From \((0, 0)\) to \((2, 3)\) takes 2 R and 3 U steps, \(\binom{5}{2} = 10\) ways; from \((2, 3)\) to \((6, 6)\) takes 4 R and 3 U steps, \(\binom{7}{4} = 35\) ways. By the product rule,
\[10\cdot 35 = 350.\](c) Subtract the paths that do go through the point:
\[924 - 350 = 574.\](a) \(924\); (b) \(350\); (c) \(574\)
Review:
57Two fair six-sided dice are rolled. (a) What is the probability that the sum is 7? (b) What is the probability that at least one die shows a 6? (c) Given that the two dice show different numbers, what is the probability that the sum is 7? Give each answer to four decimals.
Solution
The sample space has \(6\cdot 6 = 36\) equally likely ordered outcomes \((a, b)\).
(a) The outcomes with sum 7 are \((1,6), (2,5), (3,4), (4,3), (5,2), (6,1)\), six of them:
\[P(\text{sum} = 7) = \frac{6}{36} = \frac16 \approx 0.1667.\](b) Count the complement. No die shows a 6 in \(5\cdot 5 = 25\) outcomes, so at least one 6 appears in \(36 - 25 = 11\):
\[P(\text{at least one 6}) = \frac{11}{36} \approx 0.3056.\](Adding \(\tfrac{6}{36} + \tfrac{6}{36}\) double-counts \((6, 6)\); the correct union is \(6 + 6 - 1 = 11\).)
(c) Condition on the event \(D\) that the dice differ, which excludes the 6 doubles and leaves \(30\) outcomes. All six sum-7 outcomes have different numbers on the dice, so they all survive:
\[P(\text{sum} = 7 \mid D) = \frac{6}{30} = \frac15 = 0.2.\]Conditioning raised the probability from \(1/6\) to \(1/5\), because the doubles that were removed never add to 7.
(a) \(\dfrac16 \approx 0.1667\); (b) \(\dfrac{11}{36} \approx 0.3056\); (c) \(\dfrac15 = 0.2\)
Review:
58A five-card hand is dealt from a standard 52-card deck. Find the probability, to three significant figures, that the hand (a) contains exactly two aces; (b) has all five cards of the same suit; (c) consists of five red cards.
Solution
All \(\binom{52}{5} = 2{,}598{,}960\) hands are equally likely, so each probability is a count of favourable hands divided by this number.
(a) Choose 2 of the 4 aces and 3 of the other 48 cards:
\[P = \frac{\binom{4}{2}\binom{48}{3}}{\binom{52}{5}} = \frac{6\cdot 17{,}296}{2{,}598{,}960} = \frac{103{,}776}{2{,}598{,}960} \approx 0.0399.\](b) Pick the suit (4 ways), then 5 of its 13 cards:
\[P = \frac{4\binom{13}{5}}{\binom{52}{5}} = \frac{4\cdot 1287}{2{,}598{,}960} = \frac{5148}{2{,}598{,}960} \approx 0.00198.\]About one hand in 500 is a flush (counting straight flushes too).
(c) There are 26 red cards:
\[P = \frac{\binom{26}{5}}{\binom{52}{5}} = \frac{65{,}780}{2{,}598{,}960} \approx 0.0253.\]Note this is much smaller than \((1/2)^5 = 0.03125\), because each red card drawn makes the next one less likely.
(a) \(\approx 0.0399\); (b) \(\approx 0.00198\); (c) \(\approx 0.0253\)
Review: ·
59A committee of 4 is chosen at random from 6 seniors and 4 juniors. Find, to four decimals, the probability that (a) the committee has exactly 2 seniors; (b) the committee has at least one junior; (c) two particular students, Dana and Eli, are both on the committee.
Solution
There are \(\binom{10}{4} = 210\) equally likely committees.
(a) Exactly 2 seniors means 2 seniors and 2 juniors:
\[P = \frac{\binom{6}{2}\binom{4}{2}}{210} = \frac{15\cdot 6}{210} = \frac{90}{210} = \frac37 \approx 0.4286.\](b) The complement is “no juniors,” i.e. all 4 seniors, \(\binom{6}{4} = 15\) committees:
\[P = 1 - \frac{15}{210} = \frac{195}{210} = \frac{13}{14} \approx 0.9286.\](c) If Dana and Eli are both in, the other 2 members are chosen from the remaining 8 students:
\[P = \frac{\binom{8}{2}}{210} = \frac{28}{210} = \frac{2}{15} \approx 0.1333.\]Sanity check for (c): the chance Dana is chosen is \(4/10\), and given that, the chance Eli fills one of the other 3 seats is \(3/9\); the product \(\tfrac{4}{10}\cdot\tfrac{3}{9} = \tfrac{2}{15}\) agrees.
(a) \(\dfrac37 \approx 0.4286\); (b) \(\dfrac{13}{14} \approx 0.9286\); (c) \(\dfrac{2}{15} \approx 0.1333\)
Review:
60A club sells 500 raffle tickets at $2 each. One ticket wins a $400 prize and two other tickets each win $100. (a) What is the expected value of the prize won by a single ticket? (b) What is the expected net gain (prize minus cost) for someone who buys one ticket? (c) What is the club’s expected profit from the raffle?
Solution
(a) Let \(X\) be the prize for one ticket. It is $400 with probability \(1/500\), $100 with probability \(2/500\), and $0 with probability \(497/500\):
\[E[X] = 400\cdot\frac{1}{500} + 100\cdot\frac{2}{500} + 0\cdot\frac{497}{500} = 0.80 + 0.40 = \$1.20.\](b) The ticket costs $2 no matter what, so the net gain is \(X - 2\) and
\[E[X - 2] = E[X] - 2 = 1.20 - 2 = -\$0.80.\]On average a ticket loses 80 cents; that is the usual sign of a fundraiser.
(c) The club collects \(500\cdot\$2 = \$1000\) and pays out \(400 + 100 + 100 = \$600\) in prizes, for a profit of
\[1000 - 600 = \$400.\]This matches (b): 500 tickets each losing an expected $0.80 is \(500\cdot 0.80 = \$400\). The club’s profit is actually certain here, since the prize total does not depend on who wins.
(a) \(\$1.20\); (b) \(-\$0.80\); (c) \(\$400\)
Review:
61Use linearity of expectation. (a) Two fair dice are rolled; find the expected value of their sum. (b) A fair die is rolled 10 times; find the expected number of sixes, to four decimals. (c) Five people’s hats are handed back at random (each of the \(120\) orders equally likely); find the expected number of people who receive their own hat.
Solution
Linearity of expectation says \(E[X + Y] = E[X] + E[Y]\) for any random variables, independent or not. The strategy in each part is to write the quantity as a sum of simpler variables.
(a) One die has \(E = \dfrac{1 + 2 + 3 + 4 + 5 + 6}{6} = 3.5\). The sum of two dice therefore has expectation
\[3.5 + 3.5 = 7.\](b) Let \(I_k = 1\) if roll \(k\) is a six and \(0\) otherwise. Then \(E[I_k] = P(\text{six}) = \tfrac16\), and the number of sixes is \(I_1 + \cdots + I_{10}\):
\[E = 10\cdot\frac16 = \frac{5}{3} \approx 1.6667.\](c) Let \(J_k = 1\) if person \(k\) gets their own hat. Each person is equally likely to receive any of the 5 hats, so \(E[J_k] = \tfrac15\). The matches are not independent, but linearity does not care:
\[E[J_1 + \cdots + J_5] = 5\cdot\frac15 = 1.\]Remarkably, the expected number of matches is 1 no matter how many hats there are.
(a) \(7\); (b) \(\dfrac53 \approx 1.6667\); (c) \(1\)
Review:
62A quiz has 8 multiple-choice questions with 4 options each, and a student guesses every answer at random. (a) What is the probability of exactly 2 correct answers? (b) What is the probability of at least 1 correct answer? Give (a) and (b) to four decimals. (c) What is the expected number of correct answers?
Solution
Each question is an independent trial with success probability \(p = \tfrac14\), so the number of correct answers \(X\) is binomial with \(n = 8\):
\[P(X = k) = \binom{8}{k}\left(\tfrac14\right)^k\left(\tfrac34\right)^{8-k}.\](a)
\[P(X = 2) = \binom{8}{2}\left(\tfrac14\right)^2\left(\tfrac34\right)^6 = 28\cdot\frac{1}{16}\cdot\frac{729}{4096} = \frac{20{,}412}{65{,}536} \approx 0.3115.\](b) Use the complement: no correct answers means all 8 guesses are wrong.
\[P(X \ge 1) = 1 - \left(\tfrac34\right)^8 = 1 - \frac{6561}{65{,}536} = \frac{58{,}975}{65{,}536} \approx 0.8999.\](c) The expected value of a binomial variable is \(np\):
\[E[X] = 8\cdot\tfrac14 = 2.\]Guessing earns, on average, 2 of the 8 questions.
(a) \(\approx 0.3115\); (b) \(\approx 0.8999\); (c) \(2\)
Review: ·
63A factory makes parts on two machines. Machine A produces 60% of the parts, of which 2% are defective; machine B produces the other 40%, of which 5% are defective. A part is picked at random. (a) What is the probability that it is defective? (b) Given that it is defective, what is the probability that it came from machine B? (c) Given that it is not defective, what is the probability that it came from machine A? Give four decimals.
Solution
Let \(A\) and \(B\) be the machine events and \(D\) the event “defective.” We know \(P(A) = 0.6\), \(P(B) = 0.4\), \(P(D \mid A) = 0.02\), \(P(D \mid B) = 0.05\).
(a) The law of total probability splits \(D\) by machine:
\[P(D) = P(D \mid A)P(A) + P(D \mid B)P(B) = 0.02(0.6) + 0.05(0.4) = 0.012 + 0.020 = 0.032.\](b) Bayes’ theorem:
\[P(B \mid D) = \frac{P(D \mid B)P(B)}{P(D)} = \frac{0.020}{0.032} = 0.625.\]Machine B makes only 40% of the parts but 62.5% of the defective ones, because its defect rate is higher.
(c) \(P(\overline{D}) = 1 - 0.032 = 0.968\) and \(P(\overline{D} \mid A) = 0.98\):
\[P(A \mid \overline{D}) = \frac{0.98(0.6)}{0.968} = \frac{0.588}{0.968} \approx 0.6074.\]Among good parts, machine A’s share rises slightly above its 60% production share.
(a) \(0.032\); (b) \(0.625\); (c) \(\approx 0.6074\)
Review:
64Assume the 12 birth months are equally likely and independent. (a) In a group of 5 people, what is the probability that all five were born in different months? (b) What is the probability that at least two of the five share a birth month? Give four decimals. (c) What is the smallest group size for which the probability that some two people share a birth month exceeds \(1/2\)?
Solution
(a) There are \(12^5\) equally likely assignments of months to the five people. All different means the months form an arrangement of 5 of the 12 months:
\[P(\text{all different}) = \frac{12\cdot 11\cdot 10\cdot 9\cdot 8}{12^5} = \frac{95{,}040}{248{,}832} = \frac{55}{144} \approx 0.3819.\](b) “At least two share” is the complement of “all different”:
\[1 - \frac{55}{144} = \frac{89}{144} \approx 0.6181.\](c) Compute \(P(\text{share})\) for increasing group sizes \(n\):
\[n = 4:\ 1 - \frac{12\cdot 11\cdot 10\cdot 9}{12^4} = 1 - \frac{11{,}880}{20{,}736} \approx 0.4271\] \[n = 5:\ \approx 0.6181.\]So the probability first exceeds \(1/2\) at \(n = 5\). (This is the birthday problem with 12 “days”; the pigeonhole principle only guarantees a match at \(n = 13\), but a match is already more likely than not with 5 people.)
(a) \(\dfrac{55}{144} \approx 0.3819\); (b) \(\approx 0.6181\); (c) \(5\) people
Review: ·
65The number \(X\) of service calls a technician receives in a day has the distribution \(P(X = 0) = 0.1\), \(P(X = 1) = 0.3\), \(P(X = 2) = 0.4\), \(P(X = 3) = 0.2\). Find (a) the expected value \(E[X]\); (b) the variance \(\operatorname{Var}(X)\); (c) \(P(X \ge 2)\).
Solution
(a) Multiply each value by its probability and add:
\[E[X] = 0(0.1) + 1(0.3) + 2(0.4) + 3(0.2) = 0 + 0.3 + 0.8 + 0.6 = 1.7.\](b) Use \(\operatorname{Var}(X) = E[X^2] - (E[X])^2\). First
\[E[X^2] = 0^2(0.1) + 1^2(0.3) + 2^2(0.4) + 3^2(0.2) = 0.3 + 1.6 + 1.8 = 3.7\]and then
\[\operatorname{Var}(X) = 3.7 - 1.7^2 = 3.7 - 2.89 = 0.81.\]The standard deviation is \(\sqrt{0.81} = 0.9\) calls. (A common error is to compute \((E[X])^2\) as \(E[X^2]\); here they differ, \(2.89\) versus \(3.7\).)
(c) Add the probabilities of the values 2 and 3:
\[P(X \ge 2) = 0.4 + 0.2 = 0.6.\](a) \(1.7\); (b) \(0.81\) (standard deviation \(0.9\)); (c) \(0.6\)
Review:
Set 4: relations, recurrences and sequences
Discrete Math · Practice problems 66 to 80
Problems 66 to 80
One hundred problems modelled on a first discrete mathematics course. Every problem opens to a full, step-by-step solution with the final answer highlighted. Try it on paper first; the Review link at the end jumps back to the matching notes.
66Let \(R = \{(1,1), (2,2), (3,3), (4,4), (1,2), (2,1), (3,4)\}\) be a relation on \(\{1, 2, 3, 4\}\). (a) Which properties does \(R\) have? (i) reflexive only; (ii) reflexive and symmetric but not transitive; (iii) reflexive and transitive but not symmetric; (iv) reflexive, symmetric and transitive. (b) What is the smallest number of ordered pairs that must be added to \(R\) to make it an equivalence relation? (c) How many equivalence classes does that equivalence relation have?
Solution
(a) Reflexive: all four pairs \((1,1), (2,2), (3,3), (4,4)\) are present, so yes.
Symmetric: \((3,4) \in R\) but \((4,3) \notin R\), so no. (The pair \((1,2), (2,1)\) is fine; one failure is enough to break symmetry.)
Transitive: we need \((a,c) \in R\) whenever \((a,b), (b,c) \in R\). Pairs involving a diagonal element \((x,x)\) never cause trouble. The remaining combinations are \((1,2), (2,1)\), which require \((1,1)\) — present; \((2,1), (1,2)\), which require \((2,2)\) — present; and \((3,4)\) followed by something starting with 4, but the only such pair is \((4,4)\), requiring \((3,4)\) — present. So \(R\) is transitive. The answer is (iii).
(b) Add \((4,3)\). The relation is now symmetric, and it stays transitive: the new combinations \((3,4), (4,3)\) and \((4,3), (3,4)\) require \((3,3)\) and \((4,4)\), both present. One pair suffices, and at least one is needed since \(R\) itself is not symmetric:
\[1 \text{ pair}.\](c) The equivalence relation \(R \cup \{(4,3)\}\) relates 1 with 2 and 3 with 4, so its classes are \(\{1, 2\}\) and \(\{3, 4\}\):
\[2 \text{ classes}.\](a) (iii); (b) \(1\) pair, namely \((4,3)\); (c) \(2\) classes, \(\{1,2\}\) and \(\{3,4\}\)
Review:
67Consider these relations on the set of positive integers: (i) \(a\,R\,b\) iff \(a \le b\); (ii) \(a\,R\,b\) iff \(|a - b| \le 1\); (iii) \(a\,R\,b\) iff \(a + b\) is even; (iv) \(a\,R\,b\) iff \(a\) divides \(b\). (a) Which one is an equivalence relation? (b) How many equivalence classes does it have? (c) Which term best describes relation (i)? (A) an equivalence relation; (B) a partial order; (C) symmetric but not transitive; (D) not reflexive.
Solution
An equivalence relation must be reflexive, symmetric and transitive. Test each.
(i) \(a \le b\): reflexive (\(a \le a\)) and transitive, but not symmetric, since \(2 \le 3\) while \(3 \not\le 2\). Not an equivalence relation.
(ii) \(|a - b| \le 1\): reflexive and symmetric, but not transitive: \(1\,R\,2\) and \(2\,R\,3\), yet \(|1 - 3| = 2\). Not an equivalence relation.
(iii) \(a + b\) even: this holds exactly when \(a\) and \(b\) have the same parity. Reflexive: \(a + a = 2a\) is even. Symmetric: \(a + b = b + a\). Transitive: if \(a, b\) share a parity and \(b, c\) share a parity, then \(a, c\) do. An equivalence relation.
(iv) \(a \mid b\): not symmetric, since \(2 \mid 4\) but \(4 \nmid 2\). Not an equivalence relation.
(a) So the answer is (iii).
(b) Two numbers are related exactly when they have the same parity, so the classes are the odd numbers and the even numbers:
\[2 \text{ classes}.\](c) Relation (i) is reflexive, antisymmetric (\(a \le b\) and \(b \le a\) force \(a = b\)) and transitive, which is the definition of a partial order (in fact a total order, since any two integers are comparable). The answer is (B).
(a) (iii); (b) \(2\) classes (odd, even); (c) (B) a partial order
Review:
68Let \(A\) be a set with 4 elements. (a) How many relations on \(A\) are there? (b) How many of them are reflexive? (c) How many are symmetric?
Solution
A relation on \(A\) is a subset of \(A \times A\), which has \(4\cdot 4 = 16\) ordered pairs.
(a) Each of the 16 pairs is either in the relation or not:
\[2^{16} = 65{,}536.\](b) A reflexive relation must contain the 4 diagonal pairs \((a, a)\); the other \(16 - 4 = 12\) pairs are free:
\[2^{12} = 4096.\](c) A symmetric relation is determined by two kinds of choices: for each of the 4 diagonal pairs, in or out; and for each unordered pair \(\{a, b\}\) with \(a \ne b\), either both \((a, b)\) and \((b, a)\) are in or both are out. There are \(\binom{4}{2} = 6\) unordered pairs, so \(4 + 6 = 10\) independent choices:
\[2^{10} = 1024.\]In general, on an \(n\)-element set there are \(2^{n^2}\) relations, \(2^{n^2 - n}\) reflexive ones and \(2^{n(n+1)/2}\) symmetric ones.
(a) \(2^{16} = 65{,}536\); (b) \(2^{12} = 4096\); (c) \(2^{10} = 1024\)
Review: ·
69On the set \(S = \{1, 2, \dots, 12\}\) define \(a \sim b\) if and only if \(5\) divides \(a - b\). (a) How many equivalence classes does \(\sim\) have? (b) How many elements are in the equivalence class of \(2\)? (c) How many different equivalence relations are there on a set with 4 elements?
Solution
(a) \(a \sim b\) means \(a\) and \(b\) leave the same remainder on division by 5, so the classes are the sets of numbers in \(S\) with a given remainder. All five remainders \(0, 1, 2, 3, 4\) occur (for example \(5, 1, 2, 3, 4\)), so there are
\[5 \text{ classes}.\](b) The class of 2 is the set of numbers in \(S\) with remainder 2:
\[[2] = \{2, 7, 12\}\] \[3 \text{ elements}.\](Classes of remainder 1 and 2 have 3 elements; remainders 0, 3 and 4 have 2 each, and \(3 + 3 + 2 + 2 + 2 = 12\).)
(c) Equivalence relations on a set correspond exactly to partitions of the set. Count the partitions of \(\{a, b, c, d\}\) by the sizes of their blocks:
\[\begin{aligned} &4: \ 1 \text{ partition}; \qquad 3 + 1:\ \binom{4}{3} = 4; \qquad 2 + 2:\ \tfrac12\binom{4}{2} = 3; \\ &2 + 1 + 1:\ \binom{4}{2} = 6; \qquad 1 + 1 + 1 + 1:\ 1. \end{aligned}\] \[1 + 4 + 3 + 6 + 1 = 15.\]This is the Bell number \(B_4 = 15\).
(a) \(5\); (b) \(3\), since \([2] = \{2, 7, 12\}\); (c) \(15\)
Review:
70Consider the partial order \(\subseteq\) on the power set of \(\{a, b, c\}\) (eight subsets). (a) How many edges does its Hasse diagram have? (b) How many elements are in a longest chain? (c) What is the size of the largest antichain (a set of elements no two of which are comparable)?
Solution
(a) In a Hasse diagram an edge joins \(S\) to \(T\) when \(S \subset T\) with nothing strictly between them. For subsets, that means \(T = S \cup \{x\}\) for a single element \(x \notin S\). So the edges correspond to pairs (subset \(S\), element \(x\) not in \(S\)). Count by the size of \(S\): one subset of size 0 with 3 choices of \(x\), three of size 1 with 2 choices each, three of size 2 with 1 choice, and one of size 3 with none:
\[1\cdot 3 + 3\cdot 2 + 3\cdot 1 + 1\cdot 0 = 12 \text{ edges}.\](The diagram is the skeleton of a cube: 8 corners and 12 edges.)
(b) A chain is a set of mutually comparable elements. Along a chain the sizes strictly increase, and sizes run only from 0 to 3, so a chain has at most 4 elements, and
\[\varnothing \subset \{a\} \subset \{a, b\} \subset \{a, b, c\}\]achieves 4.
(c) The three singletons \(\{a\}, \{b\}, \{c\}\) are pairwise incomparable, so an antichain of size 3 exists (so does \(\{a,b\}, \{a,c\}, \{b,c\}\)). No antichain is larger: by Sperner’s theorem the largest antichain in the subsets of an \(n\)-set has \(\binom{n}{\lfloor n/2\rfloor}\) elements, here \(\binom{3}{1} = 3\). You can also check directly that any 4 subsets of \(\{a, b, c\}\) must include two that are comparable.
(a) \(12\); (b) \(4\); (c) \(3\)
Review: ·
71Let \(T = \{1, 2, 3, 4, 5, 6, 7, 8\}\) with the partial order “\(a \preceq b\) iff \(a\) divides \(b\).” (a) How many minimal elements does \((T, \preceq)\) have? (b) How many maximal elements does it have? (c) How many elements are in a longest chain?
Solution
Draw (or imagine) the Hasse diagram: 1 at the bottom, with edges joining 1 to each of 2, 3, 5 and 7; 2 to 4 and 6; 3 to 6; and 4 to 8 (eight edges in all).
(a) A minimal element has nothing below it. Since 1 divides everything, every other element has 1 below it, and 1 itself has nothing below it. So there is exactly
\[1 \text{ minimal element (namely } 1\text{)}\]which is in fact the least element.
(b) A maximal element has no proper multiple in \(T\). The elements 1, 2, 3, 4 have proper multiples in \(T\) (\(2, 4, 6, 8\) respectively); the elements 5, 6, 7, 8 do not, because \(10, 12, 14, 16 \gt 8\). So the maximal elements are \(5, 6, 7, 8\):
\[4 \text{ maximal elements}.\]There is no greatest element: no single number in \(T\) is divisible by all the others.
(c) In a chain each element is a proper multiple of the one before it, so each is at least double the previous one. Starting from 1 that gives at most \(1, 2, 4, 8\): a chain of 4 elements, and a fifth element would have to be at least 16. So a longest chain has
\[4 \text{ elements}.\](a) \(1\); (b) \(4\) (the elements \(5, 6, 7, 8\)); (c) \(4\) (e.g. \(1 \mid 2 \mid 4 \mid 8\))
Review:
72The sequence \(a_n\) satisfies \(a_n = 3a_{n-1} + 2\) for \(n \ge 1\), with \(a_0 = 1\). (a) Find \(a_3\). (b) Find a closed-form formula for \(a_n\).
Solution
(a) Iterate the recurrence:
\[a_1 = 3(1) + 2 = 5\] \[a_2 = 3(5) + 2 = 17\] \[a_3 = 3(17) + 2 = 53.\](b) For a recurrence \(a_n = ra_{n-1} + c\) the trick is to find the constant (fixed-point) solution \(a_n = k\): \(k = 3k + 2\) gives \(k = -1\). Then the shifted sequence \(b_n = a_n - k = a_n + 1\) satisfies a pure geometric recurrence:
\[b_n = a_n + 1 = 3a_{n-1} + 3 = 3(a_{n-1} + 1) = 3b_{n-1}\] \[b_0 = a_0 + 1 = 2.\]So \(b_n = 2\cdot 3^n\), and
\[a_n = 2\cdot 3^n - 1.\]Check against (a): \(a_3 = 2\cdot 27 - 1 = 53\). You can also see the formula by unrolling: \(a_n = 3^n a_0 + 2(1 + 3 + \cdots + 3^{n-1}) = 3^n + (3^n - 1) = 2\cdot 3^n - 1\).
(a) \(a_3 = 53\); (b) \(a_n = 2\cdot 3^n - 1\)
Review:
73Solve the recurrence \(a_n = 5a_{n-1} - 6a_{n-2}\) with \(a_0 = 1\) and \(a_1 = 4\). (a) Find \(a_3\) directly from the recurrence. (b) Find a closed-form formula for \(a_n\). (c) Use the formula to find \(a_6\).
Solution
(a) Compute two more terms:
\[a_2 = 5(4) - 6(1) = 14\] \[a_3 = 5(14) - 6(4) = 70 - 24 = 46.\](b) Try \(a_n = r^n\). Dividing \(r^n = 5r^{n-1} - 6r^{n-2}\) by \(r^{n-2}\) gives the characteristic equation
\[r^2 - 5r + 6 = 0\] \[\Longrightarrow\ (r - 2)(r - 3) = 0\] \[r = 2,\ 3.\]Two distinct roots, so the general solution is \(a_n = A\cdot 2^n + B\cdot 3^n\). The initial conditions give
\[n = 0:\ A + B = 1\] \[n = 1:\ 2A + 3B = 4.\]Subtracting twice the first from the second: \(B = 2\), so \(A = -1\):
\[a_n = 2\cdot 3^n - 2^n.\]Check: \(a_2 = 18 - 4 = 14\) and \(a_3 = 54 - 8 = 46\), matching (a).
(c)
\[a_6 = 2\cdot 729 - 64 = 1458 - 64 = 1394.\](a) \(46\); (b) \(a_n = 2\cdot 3^n - 2^n\); (c) \(1394\)
Review:
74Solve \(a_n = 4a_{n-1} - 4a_{n-2}\) with \(a_0 = 2\), \(a_1 = 8\). (a) Find \(a_2\). (b) Find a closed-form formula for \(a_n\). (c) Find \(a_5\).
Solution
(a) \(a_2 = 4(8) - 4(2) = 32 - 8 = 24\).
(b) The characteristic equation is
\[r^2 - 4r + 4 = (r - 2)^2 = 0\]a repeated root \(r = 2\). With a double root the two independent solutions are \(2^n\) and \(n\,2^n\), so the general solution is \(a_n = (A + Bn)2^n\). Fit the initial conditions:
\[a_0 = A = 2\] \[a_1 = (2 + B)\cdot 2 = 8 \ \Longrightarrow\ B = 2.\] \[a_n = (2 + 2n)2^n = (n + 1)2^{n+1}.\]Check: \(a_2 = 3\cdot 2^3 = 24\), as in (a). Forgetting the factor \(n\) in the second solution and writing \(a_n = A\,2^n\) cannot satisfy both initial conditions, which is the usual sign that the root is repeated.
(c)
\[a_5 = 6\cdot 2^6 = 6\cdot 64 = 384.\](a) \(24\); (b) \(a_n = (n + 1)\,2^{n+1}\); (c) \(384\)
Review:
75Max opens a savings account with $500. Each year the balance earns 10% interest, and at the end of each year Max deposits another $200. Let \(a_n\) be the balance after \(n\) years, so \(a_0 = 500\). (a) Find \(a_3\). (b) Find a closed-form formula for \(a_n\). (c) Find the balance after 10 years, to the nearest cent.
Solution
Each year the old balance is multiplied by \(1.1\) and then $200 is added:
\[a_n = 1.1\,a_{n-1} + 200\] \[a_0 = 500.\](a) Iterate:
\[a_1 = 550 + 200 = 750\] \[a_2 = 825 + 200 = 1025\] \[a_3 = 1127.5 + 200 = 1327.5.\]So \(a_3 = \$1327.50\).
(b) Find the constant solution \(k = 1.1k + 200\): \(-0.1k = 200\), so \(k = -2000\). Then \(b_n = a_n + 2000\) satisfies \(b_n = 1.1\,b_{n-1}\) with \(b_0 = 2500\), so \(b_n = 2500(1.1)^n\) and
\[a_n = 2500(1.1)^n - 2000.\]Check: \(a_3 = 2500(1.331) - 2000 = 3327.5 - 2000 = 1327.5\).
(c) \((1.1)^{10} \approx 2.593742\), so
\[a_{10} = 2500(2.593742) - 2000 \approx 6484.36 - 2000 = \$4484.36.\]Of this, $2500 is money Max put in (the opening $500 plus ten deposits); the rest is interest.
(a) \(\$1327.50\); (b) \(a_n = 2500(1.1)^n - 2000\); (c) \(\$4484.36\)
Review:
76In the Tower of Hanoi puzzle, \(n\) disks must be moved from one peg to another, one disk at a time, never placing a larger disk on a smaller one. Let \(H_n\) be the minimum number of moves. (a) How many moves are needed for 7 disks? (b) A puzzle that takes exactly 255 moves has how many disks? (c) At one move per second, how many days does the 20-disk puzzle take? Give one decimal.
Solution
To move \(n\) disks, first move the top \(n - 1\) disks to the spare peg (\(H_{n-1}\) moves), then move the largest disk (1 move), then move the \(n - 1\) disks on top of it (\(H_{n-1}\) moves):
\[H_n = 2H_{n-1} + 1\] \[H_1 = 1.\]Iterating gives \(1, 3, 7, 15, 31, \dots\), and the closed form is \(H_n = 2^n - 1\) (check: \(2(2^{n-1} - 1) + 1 = 2^n - 1\)).
(a) \(H_7 = 2^7 - 1 = 127\) moves.
(b) \(2^n - 1 = 255\) gives \(2^n = 256 = 2^8\), so \(n = 8\) disks.
(c) \(H_{20} = 2^{20} - 1 = 1{,}048{,}575\) seconds. A day has \(86{,}400\) seconds:
\[\frac{1{,}048{,}575}{86{,}400} \approx 12.1 \text{ days}.\]Each extra disk doubles the time; the legendary 64-disk version would take about \(5.8\times 10^{11}\) years.
(a) \(127\); (b) \(8\) disks; (c) \(\approx 12.1\) days
Review:
77Let \(a_n\) be the number of bit strings of length \(n\) that contain no two consecutive 1s. (a) Find \(a_4\). (b) Find \(a_{10}\). (c) How many bit strings of length 10 contain at least one pair of consecutive 1s?
Solution
Classify a valid string of length \(n\) by its last bit. If it ends in 0, the first \(n - 1\) bits form any valid string of length \(n - 1\): \(a_{n-1}\) choices. If it ends in 1, the bit before it must be 0, and the first \(n - 2\) bits form any valid string of length \(n - 2\): \(a_{n-2}\) choices. So
\[a_n = a_{n-1} + a_{n-2}\] \[a_1 = 2 \ (0, 1),\quad a_2 = 3 \ (00, 01, 10).\]This is the Fibonacci recurrence, and \(a_n = F_{n+2}\).
(a) \(a_3 = 3 + 2 = 5\) and \(a_4 = 5 + 3 = 8\). (The eight strings: \(0000, 0001, 0010, 0100, 0101, 1000, 1001, 1010\).)
(b) Continue: \(a_5 = 13,\ a_6 = 21,\ a_7 = 34,\ a_8 = 55,\ a_9 = 89,\ a_{10} = 144\).
(c) There are \(2^{10} = 1024\) strings of length 10 in all, so the ones with at least one “11” number
\[1024 - 144 = 880.\](a) \(8\); (b) \(144\); (c) \(880\)
Review: ·
78A staircase has \(n\) steps, and you climb it taking 1, 2 or 3 steps at a time. Let \(s_n\) be the number of ways to climb it. (a) Find \(s_5\). (b) Find \(s_8\). (c) If only 1- or 2-step moves were allowed, how many ways would there be to climb 10 steps?
Solution
Classify by the size of the last move. If it was 1 step, the first \(n - 1\) steps were climbed in one of \(s_{n-1}\) ways; if 2 steps, \(s_{n-2}\) ways; if 3 steps, \(s_{n-3}\) ways. So
\[s_n = s_{n-1} + s_{n-2} + s_{n-3}\] \[s_1 = 1,\quad s_2 = 2,\quad s_3 = 4.\](\(s_3 = 4\): the climbs are \(1\text{+}1\text{+}1,\ 1\text{+}2,\ 2\text{+}1,\ 3\).)
(a) \(s_4 = 4 + 2 + 1 = 7\) and \(s_5 = 7 + 4 + 2 = 13\).
(b) \(s_6 = 13 + 7 + 4 = 24\), \(s_7 = 24 + 13 + 7 = 44\), \(s_8 = 44 + 24 + 13 = 81\).
(c) With 1- and 2-step moves only, \(t_n = t_{n-1} + t_{n-2}\) with \(t_1 = 1\), \(t_2 = 2\): the sequence \(1, 2, 3, 5, 8, 13, 21, 34, 55, 89\), so \(t_{10} = 89\) (a Fibonacci number). Allowing 3-step moves as well gives \(s_{10} = 274\), about three times as many.
(a) \(13\); (b) \(81\); (c) \(89\)
Review: ·
79(a) The function \(f(n) = 3n^2 + 20n\log n + 7\) is \(\Theta(g(n))\) for which \(g\)? (i) \(n\log n\); (ii) \(n^2\); (iii) \(n^2\log n\); (iv) \(n^3\). (b) Which of the following grows fastest as \(n \to \infty\)? (i) \(n^3\); (ii) \(2^n\); (iii) \(n!\); (iv) \(n^2\log n\). (c) In the nested loop “for \(i = 1\) to \(n\): for \(j = 1\) to \(i\): print(\(i, j\))”, exactly how many lines are printed when \(n = 100\)?
Solution
(a) For large \(n\) the term with the fastest growth dominates. Since \(\log n\) grows more slowly than \(n\), \(n\log n\) grows more slowly than \(n^2\), so \(3n^2\) dominates. Formally, for \(n \ge 1\) we have \(\log n \le n\) and \(7 \le 7n^2\), hence
\[3n^2 \le f(n) \le 3n^2 + 20n^2 + 7n^2 = 30n^2\]so \(f(n) = \Theta(n^2)\): answer (ii).
(b) The standard ordering of growth rates is
\[\log n \ll n \ll n\log n \ll n^2 \ll n^3 \ll 2^n \ll n!\]and \(n^2\log n\) sits between \(n^2\) and \(n^3\). The fastest of the four is \(n!\): answer (iii). (At \(n = 20\): \(n^3 = 8000\), \(2^n \approx 10^6\), \(n! \approx 2.4\times 10^{18}\).)
(c) For each \(i\) the inner loop runs \(i\) times, so the total is
\[\sum_{i=1}^{n} i = \frac{n(n+1)}{2}\] \[\frac{100\cdot 101}{2} = 5050 \text{ lines}.\]The running time is \(\Theta(n^2)\), even though each loop on its own is linear.
(a) (ii) \(\Theta(n^2)\); (b) (iii) \(n!\); (c) \(5050\)
Review:
80The sequence \(a_n\) satisfies \(a_n = a_{n-1} + 3n\) for \(n \ge 1\), with \(a_0 = 0\). (a) Find \(a_4\). (b) Solve the recurrence by iteration to get a closed-form formula for \(a_n\). (c) What is the smallest \(n\) for which \(a_n \gt 1000\)?
Solution
(a) Build up from \(a_0\): \(a_1 = 0 + 3 = 3\), \(a_2 = 3 + 6 = 9\), \(a_3 = 9 + 9 = 18\), \(a_4 = 18 + 12 = 30\).
(b) Unroll the recurrence all the way down to \(a_0\):
\[a_n = a_{n-1} + 3n = a_{n-2} + 3(n-1) + 3n = \cdots = a_0 + 3(1 + 2 + \cdots + n).\]With \(a_0 = 0\) and the formula for the sum of the first \(n\) positive integers,
\[a_n = 3\cdot\frac{n(n+1)}{2} = \frac{3n(n+1)}{2}.\]Check: \(a_4 = \dfrac{3\cdot 4\cdot 5}{2} = 30\).
(c) We need \(\dfrac{3n(n+1)}{2} \gt 1000\), i.e. \(n(n+1) \gt 666.7\). Since \(25\cdot 26 = 650\) falls short and \(26\cdot 27 = 702\) succeeds, the answer is \(n = 26\): \(a_{25} = 975\) and \(a_{26} = 1053\).
(a) \(30\); (b) \(a_n = \dfrac{3n(n+1)}{2}\); (c) \(n = 26\)
Review:
Set 5: graphs, trees and Boolean algebra
Discrete Math · Practice problems 81 to 100
Problems 81 to 100
One hundred problems modelled on a first discrete mathematics course. Every problem opens to a full, step-by-step solution with the final answer highlighted. Try it on paper first; the Review link at the end jumps back to the matching notes.
81(a) A graph has degree sequence \(3, 3, 2, 2, 2, 2, 1, 1\). How many edges does it have? (b) Is there a graph with degree sequence \(3, 3, 3, 1, 1\)? (i) Yes, for example a path with two extra edges; (ii) No, because the degree sum is odd; (iii) No, because a simple graph on 5 vertices cannot have a vertex of degree 3; (iv) Yes, but only if multiple edges are allowed. (c) A graph has 12 edges and every vertex has degree 3. How many vertices does it have?
Solution
The handshake lemma: the sum of the degrees equals twice the number of edges, because each edge contributes 1 to the degree of each of its two endpoints.
(a)
\[\sum \deg v = 3 + 3 + 2 + 2 + 2 + 2 + 1 + 1 = 16 = 2e\] \[\Longrightarrow\ e = 8.\](b) The degree sum would be \(3 + 3 + 3 + 1 + 1 = 11\), which is odd, but \(2e\) is always even. No such graph exists, with or without multiple edges: answer (ii). (Equivalently, every graph has an even number of odd-degree vertices, and this sequence has five.)
(c) If there are \(v\) vertices each of degree 3,
\[3v = 2e = 24\] \[\Longrightarrow\ v = 8.\]The cube graph is an example: 8 vertices, 12 edges, every vertex of degree 3.
(a) \(8\) edges; (b) (ii) no, the degree sum is odd; (c) \(8\) vertices
Review:
82(a) How many edges does the complete graph \(K_8\) have? (b) How many edges does the complete bipartite graph \(K_{4,5}\) have? (c) For which \(n\) does \(K_n\) have exactly 66 edges? (d) A simple graph has 8 vertices and 10 edges. How many edges does its complement have?
Solution
(a) \(K_n\) has an edge for every pair of vertices:
\[\binom{8}{2} = \frac{8\cdot 7}{2} = 28.\](b) In \(K_{m,n}\) every vertex on one side is joined to every vertex on the other side, so there are \(mn\) edges:
\[4\cdot 5 = 20.\](Check with the handshake lemma: 4 vertices of degree 5 and 5 vertices of degree 4 give degree sum \(20 + 20 = 40 = 2\cdot 20\).)
(c) Solve \(\binom{n}{2} = 66\): \(n(n - 1) = 132 = 12\cdot 11\), so \(n = 12\).
(d) The complement contains exactly the pairs that are not edges of the graph. There are \(\binom{8}{2} = 28\) pairs in all, so the complement has
\[28 - 10 = 18 \text{ edges}.\](a) \(28\); (b) \(20\); (c) \(n = 12\); (d) \(18\)
Review:
83A connected graph has six vertices \(A, B, C, D, E, F\) with degrees \(\deg A = 4\), \(\deg B = 3\), \(\deg C = 3\), \(\deg D = 2\), \(\deg E = 4\), \(\deg F = 2\). (a) Does the graph have an Euler circuit, an Euler path but no Euler circuit, or neither? (b) How many edges does an Euler path of this graph traverse? (c) At which vertices can an Euler path start? (i) \(A\) or \(E\); (ii) \(B\) or \(C\); (iii) \(D\) or \(F\); (iv) any vertex.
Solution
Euler’s theorem for a connected graph: it has an Euler circuit (a closed walk using every edge exactly once) if and only if every vertex has even degree, and an Euler path that is not a circuit if and only if exactly two vertices have odd degree.
(a) The odd-degree vertices are \(B\) and \(C\) (both degree 3); the other four degrees are even. Exactly two odd vertices, so the graph has an Euler path but no Euler circuit: answer (ii).
(b) An Euler path uses every edge exactly once, so it traverses all the edges. By the handshake lemma,
\[e = \frac{4 + 3 + 3 + 2 + 4 + 2}{2} = \frac{18}{2} = 9 \text{ edges}.\](c) Every time a path passes through a vertex it uses two edges there, so a vertex of odd degree must be where the path starts or ends. The Euler path therefore runs from \(B\) to \(C\) or from \(C\) to \(B\): answer (ii).
(a) (ii) an Euler path but no circuit; (b) \(9\); (c) (ii) \(B\) or \(C\)
Review:
84(a) For which \(n \ge 3\) does the complete graph \(K_n\) have an Euler circuit? (i) all \(n\); (ii) even \(n\); (iii) odd \(n\); (iv) only \(n = 3\). (b) How many distinct Hamilton circuits does \(K_6\) have, if circuits that differ only in starting vertex or direction are counted as the same? (c) Which of these graphs has a Hamilton circuit? (i) \(K_{2,3}\); (ii) \(K_{3,3}\); (iii) \(K_{1,4}\); (iv) \(K_{2,4}\).
Solution
(a) In \(K_n\) every vertex has degree \(n - 1\). An Euler circuit exists exactly when all degrees are even, i.e. when \(n - 1\) is even, i.e. \(n\) is odd: answer (iii). (\(K_3\) is a triangle, \(K_5\) can be drawn in one stroke; \(K_4\) cannot.)
(b) A Hamilton circuit visits all 6 vertices once and returns to the start. Write it starting from a fixed vertex \(v\) (rotating the circuit does not change it); the other 5 vertices can then be visited in any of \(5!\) orders, and every pair of vertices is adjacent in \(K_6\), so every order is a circuit. Each circuit is produced twice, once in each direction, so the number of distinct circuits is
\[\frac{5!}{2} = \frac{120}{2} = 60.\]In general \(K_n\) has \((n-1)!/2\) Hamilton circuits.
(c) A bipartite graph’s edges all cross between the two sides, so a Hamilton circuit alternates sides and must contain equally many vertices from each. That is impossible in \(K_{2,3}\), \(K_{1,4}\) and \(K_{2,4}\). In \(K_{3,3}\), with sides \(\{a, b, c\}\) and \(\{x, y, z\}\), the circuit \(a, x, b, y, c, z, a\) works: answer (ii).
(a) (iii) odd \(n\); (b) \(60\); (c) (ii) \(K_{3,3}\)
Review:
85(a) A connected planar graph has 10 vertices and 15 edges. How many faces (regions) does a planar drawing of it have? (b) What is the largest number of edges a connected simple planar graph with 12 vertices can have? (c) Is \(K_5\) planar? (i) Yes; (ii) No, because \(e = 10\) exceeds the bound \(3v - 6 = 9\); (iii) No, because it has an odd cycle; (iv) Yes, because it has an Euler circuit.
Solution
(a) Euler’s formula for a connected planar graph: \(v - e + f = 2\). So
\[f = 2 - v + e = 2 - 10 + 15 = 7.\](b) In a simple planar graph with \(v \ge 3\), every face is bounded by at least 3 edges and every edge borders at most 2 faces, so \(3f \le 2e\). Substituting \(f = 2 - v + e\) gives \(3(2 - v + e) \le 2e\), which rearranges to
\[e \le 3v - 6 = 3(12) - 6 = 30.\]The bound is attained by triangulations (for example, the icosahedron graph has 12 vertices and 30 edges).
(c) \(K_5\) has \(v = 5\) and \(e = \binom{5}{2} = 10\), but a planar graph on 5 vertices can have at most \(3(5) - 6 = 9\) edges. So \(K_5\) is not planar: answer (ii). (Odd cycles have nothing to do with planarity, and the Euler circuit of \(K_5\) is irrelevant too.)
(a) \(7\); (b) \(30\); (c) (ii) not planar, since \(10 \gt 9\)
Review:
86(a) A connected planar graph has 20 edges, and in a planar drawing every face is bounded by exactly 4 edges. How many faces does the drawing have? (b) How many vertices does the graph have? (c) The dodecahedron graph has 20 vertices, each of degree 3. How many edges does it have? (d) How many faces does a planar drawing of the dodecahedron graph have?
Solution
(a) Add up the number of edges around every face. Each face contributes 4, and each edge is counted twice (once from each side), so
\[4f = 2e = 40\] \[\Longrightarrow\ f = 10.\](b) Euler’s formula \(v - e + f = 2\):
\[v = 2 + e - f = 2 + 20 - 10 = 12.\](The cube graph is the same kind of graph on a smaller scale: 8 vertices, 12 edges and 6 square faces, with \(4\cdot 6 = 2\cdot 12\) and \(8 - 12 + 6 = 2\).)
(c) Handshake lemma:
\[2e = 20\cdot 3 = 60\] \[\Longrightarrow\ e = 30.\](d) Euler’s formula again:
\[f = 2 - v + e = 2 - 20 + 30 = 12\]the twelve pentagonal faces of the dodecahedron. Check: \(5f = 60 = 2e\).
(a) \(10\); (b) \(12\); (c) \(30\); (d) \(12\)
Review:
87Find the chromatic number of each graph: (a) the complete graph \(K_7\); (b) the cycle \(C_9\); (c) the complete bipartite graph \(K_{4,6}\); (d) the wheel \(W_5\) (a 5-cycle plus a hub vertex adjacent to all five rim vertices).
Solution
The chromatic number \(\chi(G)\) is the least number of colours needed so that adjacent vertices get different colours.
(a) In \(K_7\) every two vertices are adjacent, so all 7 need different colours: \(\chi(K_7) = 7\).
(b) A cycle needs 2 colours if its length is even (alternate them) and 3 if its length is odd, since alternating two colours around an odd cycle makes the first and last vertices clash. \(C_9\) is odd, so \(\chi(C_9) = 3\).
(c) Any bipartite graph with at least one edge has chromatic number 2: colour one side red and the other blue. So \(\chi(K_{4,6}) = 2\), even though it has many edges.
(d) The rim of \(W_5\) is the odd cycle \(C_5\), which needs 3 colours, and the hub is adjacent to every rim vertex, so it needs a fourth colour. Four colours suffice (3 on the rim, 1 on the hub):
\[\chi(W_5) = 4.\](For a wheel with an even rim, such as \(W_6\), the answer would be 3.)
(a) \(7\); (b) \(3\); (c) \(2\); (d) \(4\)
Review:
88Six courses \(A, B, C, D, E, F\) need final exam slots. Two courses cannot share a slot if some student takes both. The conflicting pairs are \(AB, AC, BC, CD, DE, EF, DF, BE\). (a) How many vertices are in the largest complete subgraph of the conflict graph? (b) What is the minimum number of exam slots needed? (c) A seventh course \(G\) is added that conflicts with \(A\), \(B\) and \(C\). How many slots are needed now?
Solution
Model the situation as a graph: courses are vertices and conflicting pairs are edges. A valid schedule is a proper colouring (slots are colours), so the minimum number of slots is the chromatic number.
(a) \(A, B, C\) are mutually adjacent (\(AB, AC, BC\)), and so are \(D, E, F\) (\(DE, EF, DF\)). No four vertices are mutually adjacent: for instance, \(A\) has only two neighbours. So the largest complete subgraph is a triangle:
\[3 \text{ vertices}.\](b) The triangle forces at least 3 slots. Three suffice: assign
\[A \to 1,\quad B \to 2,\quad C \to 3,\quad D \to 1,\quad E \to 3,\quad F \to 2.\]Check every edge: \(AB\) (1,2), \(AC\) (1,3), \(BC\) (2,3), \(CD\) (3,1), \(DE\) (1,3), \(EF\) (3,2), \(DF\) (1,2), \(BE\) (2,3) — all different. So the minimum is
\[3 \text{ slots}.\](c) Now \(A, B, C, G\) are mutually adjacent, a \(K_4\), which needs 4 colours. Giving \(G\) a new fourth slot and keeping the schedule above works, so the minimum is
\[4 \text{ slots}.\](a) \(3\); (b) \(3\) slots; (c) \(4\) slots
Review:
89How many spanning trees does each graph have? (a) The complete graph \(K_4\). (b) The cycle \(C_6\). (c) The complete bipartite graph \(K_{2,3}\).
Solution
A spanning tree uses all the vertices and \(n - 1\) of the edges, with no cycle.
(a) Cayley’s formula says \(K_n\) has \(n^{n-2}\) spanning trees:
\[4^{2} = 16.\](Directly: a tree on 4 vertices is a path or a star. There are \(4!/2 = 12\) labelled paths and 4 labelled stars, \(12 + 4 = 16\).)
(b) \(C_6\) has 6 edges and a spanning tree needs 5, so exactly one edge is removed, and removing any one edge of a cycle leaves a path. So there are
\[6 \text{ spanning trees}.\](c) Let the sides be \(\{u, v\}\) and \(\{x, y, z\}\); there are 6 edges and a spanning tree keeps 4, so 2 edges are removed, \(\binom{6}{2} = 15\) ways. The result fails to be a spanning tree only if some vertex is isolated: that happens exactly when both edges at the same vertex \(x\), \(y\) or \(z\) are removed (3 ways; \(u\) and \(v\) have degree 3 and cannot be isolated by removing 2 edges). Every other removal leaves a connected graph with 4 edges on 5 vertices, which is a tree:
\[15 - 3 = 12.\]This agrees with the general formula \(m^{n-1}n^{m-1} = 2^{2}\cdot 3^{1} = 12\) for \(K_{m,n}\).
(a) \(16\); (b) \(6\); (c) \(12\)
Review: ·
90Let \(G\) be the graph with vertices \(1, 2, 3, 4\) and edges \(12, 13, 23, 24, 34\) (that is, \(K_4\) with the edge \(14\) removed: two triangles sharing the edge \(23\)). (a) How many spanning trees does \(G\) have? (b) How many of them contain the edge \(23\)? (c) How many of them do not contain the edge \(23\)?
Solution
Every spanning tree of \(G\) has 3 edges. Split the count by whether the shared edge \(23\) is used (deletion–contraction).
(c) Trees that avoid \(23\) are spanning trees of \(G - 23\), which is the 4-cycle \(1, 2, 4, 3, 1\) (edges \(12, 24, 43, 31\)). A cycle of length 4 has 4 spanning trees (remove any one edge):
\[4.\](b) Trees that use \(23\) need two more edges, one connecting vertex 1 and one connecting vertex 4, with no cycle. Vertex 1 attaches by \(12\) or \(13\) (2 choices), vertex 4 by \(24\) or \(34\) (2 choices), and any combination is a tree since 1 and 4 each hang off the edge \(23\):
\[2\cdot 2 = 4.\](This is the count for the contracted graph \(G/23\), which has a double edge from 1 to the merged vertex and a double edge from it to 4.)
(a) Adding the two cases,
\[4 + 4 = 8 \text{ spanning trees}.\]Check: \(G\) has 5 edges, so a spanning tree is chosen by removing 2 edges, \(\binom{5}{2} = 10\) ways; the removals that leave a cycle are those removing both edges at vertex 1 or both at vertex 4 (each leaves a triangle plus an isolated vertex), 2 ways, and \(10 - 2 = 8\).
(a) \(8\); (b) \(4\); (c) \(4\)
Review: ·
91(a) How many edges does a tree with 25 vertices have? (b) A tree has three vertices of degree 3, two vertices of degree 2, and all its other vertices are leaves. How many leaves does it have? (c) A full binary tree has 15 internal vertices. How many leaves does it have?
Solution
(a) A tree with \(n\) vertices always has \(n - 1\) edges:
\[25 - 1 = 24.\](b) Let \(\ell\) be the number of leaves. The tree has \(n = 3 + 2 + \ell = 5 + \ell\) vertices and therefore \(n - 1 = 4 + \ell\) edges. By the handshake lemma the degrees sum to twice the number of edges:
\[3\cdot 3 + 2\cdot 2 + 1\cdot\ell = 2(4 + \ell)\] \[\Longrightarrow\ 13 + \ell = 8 + 2\ell\] \[\Longrightarrow\ \ell = 5.\]So the tree has 10 vertices and 9 edges; check: \(9 + 4 + 5 = 18 = 2\cdot 9\).
(c) In a full binary tree every internal vertex has exactly 2 children. With \(i\) internal vertices there are \(2i\) children in all, and every vertex except the root is a child, so \(n = 2i + 1\) vertices and
\[\ell = n - i = i + 1 = 16 \text{ leaves}.\](Here \(n = 31\) vertices, 15 internal and 16 leaves.)
(a) \(24\); (b) \(5\); (c) \(16\)
Review:
92(a) A full 3-ary tree (every internal vertex has exactly 3 children) has 41 leaves. How many internal vertices does it have? (b) How many vertices does it have in total? (c) What is the minimum possible height of a binary tree with 100 leaves?
Solution
(a) In a full \(m\)-ary tree with \(i\) internal vertices there are \(mi\) children, so \(n = mi + 1\) vertices, and the leaves number \(\ell = n - i = (m - 1)i + 1\). Solving for \(i\):
\[i = \frac{\ell - 1}{m - 1} = \frac{41 - 1}{2} = 20.\](b)
\[n = mi + 1 = 3(20) + 1 = 61\]which agrees with \(20\) internal vertices plus \(41\) leaves.
(c) A binary tree of height \(h\) has at most \(2^h\) leaves (the number of vertices at most doubles from one level to the next). Since \(2^6 = 64 \lt 100 \le 128 = 2^7\), a tree with 100 leaves needs height at least 7, and height 7 is enough (take a full tree of height 7 and prune down to 100 leaves). So the minimum height is
\[\lceil\log_2 100\rceil = 7.\](a) \(20\); (b) \(61\); (c) \(7\)
Review:
93A graph has vertices \(a, b, c, d, e, f, g\) and edges \(ac, ae, bc, bf, de, df, fg\). Run breadth-first search from \(a\), always visiting the neighbours of a vertex in alphabetical order. (a) List the vertices in the order they are visited, separated by commas. (b) What is the distance (number of edges on a shortest path) from \(a\) to \(g\)? (c) How many edges of the graph are not in the BFS tree?
Solution
Adjacency lists in alphabetical order: \(a: c, e\); \(b: c, f\); \(c: a, b\); \(d: e, f\); \(e: a, d\); \(f: b, d, g\); \(g: f\).
(a) BFS keeps a queue. Visit \(a\) and enqueue its unvisited neighbours \(c, e\). Dequeue \(c\): its new neighbour is \(b\). Dequeue \(e\): its new neighbour is \(d\). Dequeue \(b\): new neighbour \(f\). Dequeue \(d\): \(f\) is already queued, nothing new. Dequeue \(f\): new neighbour \(g\). Dequeue \(g\). The visiting order is
\[a,\ c,\ e,\ b,\ d,\ f,\ g.\](b) BFS visits vertices level by level: level 0 is \(\{a\}\), level 1 is \(\{c, e\}\), level 2 is \(\{b, d\}\), level 3 is \(\{f\}\), level 4 is \(\{g\}\). So the distance from \(a\) to \(g\) is
\[4\]realised for example by the path \(a, c, b, f, g\) (or \(a, e, d, f, g\)).
(c) The BFS tree contains the edge by which each vertex was first discovered: \(ac, ae, cb, ed, bf, fg\), six edges (one per non-root vertex). The graph has 7 edges, so exactly
\[7 - 6 = 1\]edge, namely \(df\), is not in the tree. It joins two vertices on consecutive levels (\(d\) on level 2, \(f\) on level 3), as every non-tree edge of a BFS must join vertices on the same or adjacent levels.
(a) \(a, c, e, b, d, f, g\); (b) \(4\); (c) \(1\) (the edge \(df\))
Review:
94A graph has vertices \(p, q, r, s, t, u\) and edges \(pq, ps, qr, qt, rs, su, tu\). (a) Run depth-first search from \(p\), always choosing the alphabetically first unvisited neighbour, and list the vertices in the order they are first visited, separated by commas. (b) How many edges of the graph are not in the DFS tree? (c) List the order in which breadth-first search from \(p\) visits the vertices, with neighbours again taken alphabetically.
Solution
Adjacency lists in alphabetical order: \(p: q, s\); \(q: p, r, t\); \(r: q, s\); \(s: p, r, u\); \(t: q, u\); \(u: s, t\).
(a) DFS goes as deep as it can before backtracking. From \(p\) go to \(q\) (its first neighbour). From \(q\), \(p\) is visited, so go to \(r\). From \(r\), \(q\) is visited, so go to \(s\). From \(s\), \(p\) and \(r\) are visited, so go to \(u\). From \(u\), \(s\) is visited, so go to \(t\). From \(t\), both \(q\) and \(u\) are visited: backtrack all the way; everything has been visited. The order is
\[p,\ q,\ r,\ s,\ u,\ t.\](b) The DFS tree edges are \(pq, qr, rs, su, ut\), five edges, one per vertex other than the root. The graph has 7 edges, so
\[7 - 5 = 2\]edges (\(ps\) and \(qt\)) are not in the tree. Both are back edges: each joins a vertex to one of its ancestors in the DFS tree (\(s\) to \(p\), \(t\) to \(q\)), as all non-tree edges of a DFS in an undirected graph must.
(c) BFS from \(p\): visit \(p\), enqueue \(q, s\). Dequeue \(q\): enqueue \(r, t\). Dequeue \(s\): \(r\) is already queued, enqueue \(u\). Then \(r, t, u\) are dequeued with nothing new. The order is
\[p,\ q,\ s,\ r,\ t,\ u.\]Notice how different the two orders are: DFS followed one long path \(p, q, r, s, u, t\), while BFS visited \(p\)’s two neighbours before anything else.
(a) \(p, q, r, s, u, t\); (b) \(2\); (c) \(p, q, s, r, t, u\)
Review:
95A weighted graph has vertices \(A\) to \(F\) and edges with weights \(AB = 4\), \(AC = 2\), \(BC = 5\), \(BD = 10\), \(CD = 8\), \(CE = 3\), \(DE = 7\), \(DF = 6\), \(EF = 9\). (a) Use Kruskal’s algorithm to find the total weight of a minimum spanning tree. (b) Which is the first edge that Kruskal’s algorithm rejects? (i) \(AB\); (ii) \(BC\); (iii) \(CD\); (iv) \(DE\). (c) What is the weight of the heaviest edge in the minimum spanning tree?
Solution
Kruskal’s algorithm sorts the edges by weight and accepts each edge unless it would close a cycle with the edges already accepted, stopping when \(n - 1 = 5\) edges have been accepted.
Sorted edges: \(AC\ (2),\ CE\ (3),\ AB\ (4),\ BC\ (5),\ DF\ (6),\ DE\ (7),\ CD\ (8),\ EF\ (9),\ BD\ (10)\).
\(AC\): accept. \(CE\): accept. \(AB\): accept (components so far: \(\{A, B, C, E\}\), \(\{D\}\), \(\{F\}\)). \(BC\): \(B\) and \(C\) are already connected, so this edge would close the cycle \(A, B, C\): reject. \(DF\): accept. \(DE\): accept; this joins \(\{D, F\}\) to \(\{A, B, C, E\}\), and we now have 5 edges, so stop.
(a) The tree is \(AC, CE, AB, DF, DE\) with total weight
\[2 + 3 + 4 + 6 + 7 = 22.\](b) The first rejected edge is \(BC\) (weight 5): answer (ii).
(c) The heaviest edge in the tree is \(DE\), with weight \(7\). (Any spanning tree must connect \(\{D, F\}\) to the rest, and the cheapest edge doing so is \(DE = 7\), so no spanning tree can avoid an edge of weight at least 7.)
(a) \(22\); (b) (ii) \(BC\); (c) \(7\)
Review: ·
96A weighted graph has vertices \(s, a, b, c, t\) and edges \(sa = 7\), \(sb = 2\), \(ab = 3\), \(ac = 2\), \(at = 4\), \(bc = 8\), \(ct = 1\). (a) Use Dijkstra’s algorithm to find the length of a shortest path from \(s\) to \(t\). (b) List the vertices of that shortest path in order, separated by commas. (c) What is the shortest distance from \(s\) to \(c\)?
Solution
Dijkstra’s algorithm keeps a tentative distance for every vertex, repeatedly settles the unsettled vertex with the smallest tentative distance, and relaxes its edges.
Start: \(d(s) = 0\), all others \(\infty\).
Settle \(s\): \(d(a) = 7\) (via \(sa\)), \(d(b) = 2\) (via \(sb\)).
Settle \(b\) (smallest, 2): \(d(a) = \min(7,\ 2 + 3) = 5\) (now via \(b\)); \(d(c) = 2 + 8 = 10\).
Settle \(a\) (5): \(d(c) = \min(10,\ 5 + 2) = 7\) (now via \(a\)); \(d(t) = 5 + 4 = 9\).
Settle \(c\) (7): \(d(t) = \min(9,\ 7 + 1) = 8\) (now via \(c\)).
Settle \(t\) (8): done.
(a) The shortest \(s\)–\(t\) distance is \(8\).
(b) Trace the predecessors backwards: \(t\) came from \(c\), \(c\) from \(a\), \(a\) from \(b\), \(b\) from \(s\):
\[s,\ b,\ a,\ c,\ t\] \[2 + 3 + 2 + 1 = 8.\]The direct-looking route \(s, a, t\) costs \(7 + 4 = 11\); the detour through \(b\) is cheaper.
(c) From the table, \(d(c) = 7\), via \(s, b, a, c\).
(a) \(8\); (b) \(s, b, a, c, t\); (c) \(7\)
Review:
97Let \(F(x, y, z) = xy + \overline{x}\,z + yz\), where juxtaposition is AND, \(+\) is OR and the bar is NOT. (a) For how many of the 8 input triples \((x, y, z)\) is \(F = 1\)? (b) Which expression is equivalent to \(F\)? (i) \(xy + \overline{x}\,z\); (ii) \(xy + yz\); (iii) \(\overline{x}\,z + yz\); (iv) \(x + z\).
Solution
(a) Find the inputs that make each product 1. \(xy = 1\) needs \(x = y = 1\): the triples \(110, 111\). \(\overline{x}\,z = 1\) needs \(x = 0, z = 1\): the triples \(001, 011\). \(yz = 1\) needs \(y = z = 1\): the triples \(011, 111\), both already listed. So \(F = 1\) exactly on
\[001,\ 011,\ 110,\ 111\]that is, \(4\) of the 8 rows.
(b) Part (a) shows the term \(yz\) adds no new rows: whenever \(y = z = 1\), either \(x = 1\) (so \(xy = 1\)) or \(x = 0\) (so \(\overline{x}\,z = 1\)). Hence \(yz\) is redundant and
\[F = xy + \overline{x}\,z.\]This is the consensus theorem: \(xy + \overline{x}z + yz = xy + \overline{x}z\). Answer (i). The other options are wrong: (ii) \(xy + yz\) is 0 at \(001\); (iii) is 0 at \(110\); (iv) \(x + z\) is 1 at \(100\), where \(F = 0\).
(a) \(4\) rows; (b) (i) \(xy + \overline{x}\,z\)
Review:
98Let \(F(x, y, z) = (x + \overline{y})(\overline{x} + z) + y\,\overline{z}\). (a) Find \(F(1, 0, 1)\). (b) Find \(F(0, 1, 0)\). (c) For how many of the 8 input triples is \(F = 1\)?
Solution
Evaluate with the rules \(1 + \text{anything} = 1\), \(0\cdot\text{anything} = 0\), \(\overline{0} = 1\), \(\overline{1} = 0\).
(a) At \((1, 0, 1)\): \(x + \overline{y} = 1 + 1 = 1\); \(\overline{x} + z = 0 + 1 = 1\); their product is 1, so \(F = 1\) regardless of the last term (which is \(0\cdot 0 = 0\)). So \(F(1, 0, 1) = 1\).
(b) At \((0, 1, 0)\): \(x + \overline{y} = 0 + 0 = 0\), so the product is 0. The last term is \(y\,\overline{z} = 1\cdot 1 = 1\). So \(F(0, 1, 0) = 0 + 1 = 1\).
(c) Go through all eight rows. The product \((x + \overline{y})(\overline{x} + z)\) is 1 when both factors are 1: if \(x = 1\) the first factor is 1 and the second needs \(z = 1\) (rows \(101, 111\)); if \(x = 0\) the second factor is 1 and the first needs \(y = 0\) (rows \(000, 001\)). The term \(y\,\overline{z}\) is 1 on rows \(010, 110\). Altogether
\[F = 1 \text{ on } 000, 001, 010, 101, 110, 111\]six rows, and \(F = 0\) on \(011\) and \(100\). So the answer is \(6\).
(a) \(1\); (b) \(1\); (c) \(6\)
Review:
99Let \(F(x, y, z) = x(y + \overline{z})\). (a) Use De Morgan’s laws to find the complement \(\overline{F}\). (i) \(\overline{x} + \overline{y}\,z\); (ii) \(\overline{x}(\overline{y} + z)\); (iii) \(\overline{x} + \overline{y} + z\); (iv) \(\overline{x}\,\overline{y}\,z\). (b) For how many input triples is \(\overline{F} = 1\)? (c) How many minterms appear in the sum-of-products (minterm) expansion of \(F\)?
Solution
(a) De Morgan’s laws: \(\overline{AB} = \overline{A} + \overline{B}\) and \(\overline{A + B} = \overline{A}\,\overline{B}\). Apply them from the outside in:
\[\overline{F} = \overline{x(y + \overline{z})} = \overline{x} + \overline{(y + \overline{z})} = \overline{x} + \overline{y}\,\overline{\overline{z}} = \overline{x} + \overline{y}\,z.\]Answer (i). (Option (iii) forgets that the inner OR becomes an AND; option (ii) applies the wrong law to the outer product.)
(c) First find where \(F = 1\): we need \(x = 1\) and \(y + \overline{z} = 1\), i.e. \(y = 1\) or \(z = 0\). With \(x = 1\) the pairs \((y, z)\) satisfying this are \((0, 0), (1, 0), (1, 1)\); only \((0, 1)\) fails. So \(F = 1\) on the three rows \(100, 110, 111\), and its minterm expansion has 3 terms:
\[F = x\overline{y}\,\overline{z} + xy\overline{z} + xyz.\](b) \(\overline{F}\) is 1 exactly where \(F\) is 0: the remaining
\[8 - 3 = 5 \text{ rows}.\]Check against (a): \(\overline{x} + \overline{y}z\) is 1 on the four rows with \(x = 0\) plus the row \(101\), five rows in total.
(a) (i) \(\overline{x} + \overline{y}\,z\); (b) \(5\); (c) \(3\)
Review:
100(a) How many different Boolean functions of three variables \(x, y, z\) are there? (b) How many different Boolean functions of two variables are there? (c) The function \(G(x, y, z)\) whose minterm expansion is \(\overline{x}\,\overline{y}\,\overline{z} + \overline{x}\,y\,\overline{z} + x\overline{y}\,\overline{z} + xy\overline{z}\) simplifies to which expression? (i) \(\overline{z}\); (ii) \(\overline{x}\); (iii) \(\overline{x}\,\overline{z}\); (iv) \(\overline{x} + \overline{z}\).
Solution
(a) A Boolean function of \(n\) variables is determined by its truth table, which has \(2^n\) rows, and each row can independently be assigned 0 or 1. So there are \(2^{2^n}\) functions. For \(n = 3\):
\[2^{2^3} = 2^8 = 256.\](b) For \(n = 2\):
\[2^{2^2} = 2^4 = 16.\](These include the familiar AND, OR, XOR, NAND, implication, the two constants, the projections and their negations.)
(c) The four minterms are exactly the rows \(000, 010, 100, 110\): every combination of \(x\) and \(y\), always with \(z = 0\). Algebraically, factor in pairs:
\[\overline{x}\,\overline{z}(\overline{y} + y) + x\overline{z}(\overline{y} + y) = \overline{x}\,\overline{z} + x\overline{z} = \overline{z}(\overline{x} + x) = \overline{z}.\]So \(G = \overline{z}\): answer (i). Check the count: \(\overline{z}\) is 1 on 4 of the 8 rows, matching the 4 minterms.
(a) \(2^8 = 256\); (b) \(16\); (c) (i) \(\overline{z}\)
Review: ·