From 23dca10ce3f2f1c9a6ffe73a0f75c3b59ea6b07e Mon Sep 17 00:00:00 2001 From: Krzysztof Wojtas Date: Mon, 8 May 2023 23:37:31 +0200 Subject: [PATCH] typeset chapters and appendices by scanning through the sources --- appendixa/main.tex | 5 ----- appendixa/problems/1/a.tex | 1 - appendixa/problems/1/b.tex | 1 - appendixa/problems/1/c.tex | 1 - appendixa/problems/1/main.tex | 5 ----- appendixa/sections/1/1.tex | 1 - appendixa/sections/1/10.tex | 1 - appendixa/sections/1/11.tex | 1 - appendixa/sections/1/2.tex | 1 - appendixa/sections/1/3.tex | 1 - appendixa/sections/1/4.tex | 1 - appendixa/sections/1/5.tex | 1 - appendixa/sections/1/6.tex | 1 - appendixa/sections/1/7.tex | 1 - appendixa/sections/1/8.tex | 1 - appendixa/sections/1/9.tex | 1 - appendixa/sections/1/main.tex | 12 ---------- appendixa/sections/2/1.tex | 1 - appendixa/sections/2/2.tex | 1 - appendixa/sections/2/3.tex | 1 - appendixa/sections/2/4.tex | 1 - appendixa/sections/2/5.tex | 1 - appendixa/sections/2/main.tex | 6 ----- appendixb/main.tex | 10 --------- appendixb/problems/1/a.tex | 1 - appendixb/problems/1/b.tex | 1 - appendixb/problems/1/c.tex | 1 - appendixb/problems/1/d.tex | 1 - appendixb/problems/1/main.tex | 5 ----- appendixb/problems/2/a.tex | 1 - appendixb/problems/2/b.tex | 1 - appendixb/problems/2/c.tex | 1 - appendixb/problems/2/d.tex | 1 - appendixb/problems/2/main.tex | 5 ----- appendixb/problems/3/a.tex | 1 - appendixb/problems/3/b.tex | 3 +-- appendixb/problems/3/c.tex | 1 - appendixb/problems/3/main.tex | 4 ---- appendixb/sections/1/1.tex | 3 +-- appendixb/sections/1/2.tex | 1 - appendixb/sections/1/3.tex | 1 - appendixb/sections/1/4.tex | 1 - appendixb/sections/1/5.tex | 1 - appendixb/sections/1/6.tex | 1 - appendixb/sections/1/main.tex | 7 ------ appendixb/sections/2/1.tex | 1 - appendixb/sections/2/2.tex | 1 - appendixb/sections/2/3.tex | 1 - appendixb/sections/2/4.tex | 1 - appendixb/sections/2/5.tex | 1 - appendixb/sections/2/main.tex | 6 ----- appendixb/sections/3/1.tex | 1 - appendixb/sections/3/2.tex | 1 - appendixb/sections/3/3.tex | 1 - appendixb/sections/3/4.tex | 3 +-- appendixb/sections/3/main.tex | 5 ----- appendixb/sections/4/1.tex | 1 - appendixb/sections/4/2.tex | 1 - appendixb/sections/4/3.tex | 1 - appendixb/sections/4/4.tex | 1 - appendixb/sections/4/5.tex | 5 ++--- appendixb/sections/4/6.tex | 1 - appendixb/sections/4/main.tex | 7 ------ appendixb/sections/5/1.tex | 9 ++++---- appendixb/sections/5/2.tex | 1 - appendixb/sections/5/3.tex | 1 - appendixb/sections/5/4.tex | 1 - appendixb/sections/5/5.tex | 1 - appendixb/sections/5/6.tex | 1 - appendixb/sections/5/7.tex | 1 - appendixb/sections/5/8.tex | 1 - appendixb/sections/5/main.tex | 9 -------- clrs4e-solutions.tex | 42 +++++++++++++++++++++++++++++++++-- 73 files changed, 49 insertions(+), 156 deletions(-) delete mode 100644 appendixa/main.tex delete mode 100644 appendixa/sections/1/main.tex delete mode 100644 appendixa/sections/2/main.tex delete mode 100644 appendixb/main.tex delete mode 100644 appendixb/problems/1/main.tex delete mode 100644 appendixb/problems/2/main.tex delete mode 100644 appendixb/problems/3/main.tex delete mode 100644 appendixb/sections/1/main.tex delete mode 100644 appendixb/sections/2/main.tex delete mode 100644 appendixb/sections/3/main.tex delete mode 100644 appendixb/sections/4/main.tex delete mode 100644 appendixb/sections/5/main.tex diff --git a/appendixa/main.tex b/appendixa/main.tex deleted file mode 100644 index 46358ed..0000000 --- a/appendixa/main.tex +++ /dev/null @@ -1,5 +0,0 @@ -\chapter{Summations} -\subimport{sections/1/}{main} -\subimport{sections/2/}{main} -\problems -\subimport{problems/1/}{main} diff --git a/appendixa/problems/1/a.tex b/appendixa/problems/1/a.tex index 4f8d2cc..6d6932a 100644 --- a/appendixa/problems/1/a.tex +++ b/appendixa/problems/1/a.tex @@ -1,4 +1,3 @@ -\subproblem Asymptotic upper bound: \begin{align*} \sum_{k=1}^n k^r &\le \sum_{k=1}^n n^r \\ diff --git a/appendixa/problems/1/b.tex b/appendixa/problems/1/b.tex index 09c825b..5c74561 100644 --- a/appendixa/problems/1/b.tex +++ b/appendixa/problems/1/b.tex @@ -1,4 +1,3 @@ -\subproblem Asymptotic upper bound: \begin{align*} \sum_{k=1}^n \lg^s k &\le \sum_{k=1}^n \lg^s n \\ diff --git a/appendixa/problems/1/c.tex b/appendixa/problems/1/c.tex index da43251..c090c45 100644 --- a/appendixa/problems/1/c.tex +++ b/appendixa/problems/1/c.tex @@ -1,4 +1,3 @@ -\subproblem Asymptotic upper bound: \begin{align*} \sum_{k=1}^n k^r \lg^s k &\le \sum_{k=1}^n n^r \lg^s n \\ diff --git a/appendixa/problems/1/main.tex b/appendixa/problems/1/main.tex index a7c75d2..83b2bc5 100644 --- a/appendixa/problems/1/main.tex +++ b/appendixa/problems/1/main.tex @@ -1,7 +1,2 @@ -\problem{Bounding summations} In order to determine the asymptotic tight bounds on each summation, we will find their asymptotic upper bound and asymptotic lower bound by substituting each term in the summations by appropriate values. Since the bounds on the summations don't depend on the parity of $n$, for simplicity we will assume that $n$ is even. - -\subimport{./}{a} -\subimport{./}{b} -\subimport{./}{c} diff --git a/appendixa/sections/1/1.tex b/appendixa/sections/1/1.tex index ab81d81..092e52d 100644 --- a/appendixa/sections/1/1.tex +++ b/appendixa/sections/1/1.tex @@ -1,4 +1,3 @@ -\exercise Let $g_1$, $g_2$, \dots, $g_n$ be functions, so that $g_k(i)=O(f_k(i))$ for each $k=1$, 2, \dots, $n$. From the definition of $O$-notation, there exist positive constants $c_1$, $c_2$, \dots, $c_n$ and $i_0$, such that $g_k(i)\le c_k f_k(i)$ for all $i\ge i_0$. Let $c=\max\,\{c_k: 1\le k\le n\}$. diff --git a/appendixa/sections/1/10.tex b/appendixa/sections/1/10.tex index d8ceb8d..261f5e6 100644 --- a/appendixa/sections/1/10.tex +++ b/appendixa/sections/1/10.tex @@ -1,4 +1,3 @@ -\exercise By formulas (A.7) and (A.11), we have: \begin{align*} \sum_{k=1}^\infty(2k+1)x^{2k} &= 2\sum_{k=0}^\infty k(x^2)^k + \sum_{k=0}^\infty(x^2)^k-1 \\ diff --git a/appendixa/sections/1/11.tex b/appendixa/sections/1/11.tex index e4ac3ee..2557adc 100644 --- a/appendixa/sections/1/11.tex +++ b/appendixa/sections/1/11.tex @@ -1,4 +1,3 @@ -\exercise We have \begin{align*} \prod_{k=2}^n\biggl(1-\frac{1}{k^2}\biggr) &= \prod_{k=2}^n\frac{k^2-1}{k^2} \\[3pt] diff --git a/appendixa/sections/1/2.tex b/appendixa/sections/1/2.tex index eec6bd0..58e828b 100644 --- a/appendixa/sections/1/2.tex +++ b/appendixa/sections/1/2.tex @@ -1,4 +1,3 @@ -\exercise We apply the linearity property and formula (A.1): \begin{align*} \sum_{k=1}^n(2k-1) &= 2\sum_{k=1}^n k - \sum_{k=1}^n 1 \\ diff --git a/appendixa/sections/1/3.tex b/appendixa/sections/1/3.tex index fa64fed..8ad54e9 100644 --- a/appendixa/sections/1/3.tex +++ b/appendixa/sections/1/3.tex @@ -1,4 +1,3 @@ -\exercise If we let $x=10$ in equation (A.6), we have: \begin{align*} 111{,}111{,}111 &= \sum_{k=0}^8 10^k \\ diff --git a/appendixa/sections/1/4.tex b/appendixa/sections/1/4.tex index d23afc2..d67b296 100644 --- a/appendixa/sections/1/4.tex +++ b/appendixa/sections/1/4.tex @@ -1,4 +1,3 @@ -\exercise Each subsequent term is the previous term multiplied by $-1/2$, so letting $x=-1/2$ in equation (A.7) gives us the value of the series: \begin{align*} \sum_{k=0}^\infty(-1/2)^k &= \frac{1}{1-(-1/2)} \\ diff --git a/appendixa/sections/1/5.tex b/appendixa/sections/1/5.tex index 402db5a..b1e6ee9 100644 --- a/appendixa/sections/1/5.tex +++ b/appendixa/sections/1/5.tex @@ -1,4 +1,3 @@ -\exercise For the upper bound, we bound $k$ by $n$: \begin{align*} \sum_{k=1}^n k^c &\le \sum_{k=1}^n n^c \\ diff --git a/appendixa/sections/1/6.tex b/appendixa/sections/1/6.tex index aed07b6..2dc0d21 100644 --- a/appendixa/sections/1/6.tex +++ b/appendixa/sections/1/6.tex @@ -1,4 +1,3 @@ -\exercise Let's differentiate both sides of equation (A.11): \begin{align*} \sum_{k=0}^\infty k\cdot kx^{k-1} &= \frac{(1-x)^2+2x(1-x)}{(1-x)^4} \\ diff --git a/appendixa/sections/1/7.tex b/appendixa/sections/1/7.tex index 5dd2992..8ba1b05 100644 --- a/appendixa/sections/1/7.tex +++ b/appendixa/sections/1/7.tex @@ -1,4 +1,3 @@ -\exercise The asymptotic upper bound: \begin{align*} \sum_{k=1}^n \sqrt{k\lg k} &\le \sum_{k=1}^n \sqrt{n\lg n} \\ diff --git a/appendixa/sections/1/8.tex b/appendixa/sections/1/8.tex index 29b05a9..d828af3 100644 --- a/appendixa/sections/1/8.tex +++ b/appendixa/sections/1/8.tex @@ -1,4 +1,3 @@ -\exercise By the upper bound on $H_n$ (A.9), we have: \begin{align*} \sum_{k=1}^n\frac{1}{2k-1} &< 1+\sum_{k=2}^{n+1}\frac{1}{2k-2} \\ diff --git a/appendixa/sections/1/9.tex b/appendixa/sections/1/9.tex index d624b38..726ac86 100644 --- a/appendixa/sections/1/9.tex +++ b/appendixa/sections/1/9.tex @@ -1,4 +1,3 @@ -\exercise By formulas (A.7) and (A.11), we have: \begin{align*} \sum_{k=0}^\infty\frac{k-1}{2^k} &= \sum_{k=0}^\infty\frac{k}{2^k} - \sum_{k=0}^\infty\frac{1}{2^k} \\ diff --git a/appendixa/sections/1/main.tex b/appendixa/sections/1/main.tex deleted file mode 100644 index 977f1c0..0000000 --- a/appendixa/sections/1/main.tex +++ /dev/null @@ -1,12 +0,0 @@ -\section{Summation formulas and properties} -\subimport{./}{1} -\subimport{./}{2} -\subimport{./}{3} -\subimport{./}{4} -\subimport{./}{5} -\subimport{./}{6} -\subimport{./}{7} -\subimport{./}{8} -\subimport{./}{9} -\subimport{./}{10} -\subimport{./}{11} diff --git a/appendixa/sections/2/1.tex b/appendixa/sections/2/1.tex index 14fa5da..10c35c0 100644 --- a/appendixa/sections/2/1.tex +++ b/appendixa/sections/2/1.tex @@ -1,4 +1,3 @@ -\exercise Using the properties of telescoping series, we get \begin{align*} \sum_{k=1}^n\frac{1}{k^2} &\le 1 + \sum_{k=2}^n\frac{1}{k(k-1)} \\ diff --git a/appendixa/sections/2/2.tex b/appendixa/sections/2/2.tex index 10126da..76a3255 100644 --- a/appendixa/sections/2/2.tex +++ b/appendixa/sections/2/2.tex @@ -1,4 +1,3 @@ -\exercise Thanks to inequality $\lceil n\rceil < n+1$ (3.2) and identity (A.7), we can write: \begin{align*} \sum_{k=0}^{\lfloor\lg n\rfloor} \left\lceil\frac{n}{2^k}\right\rceil &< \sum_{k=0}^{\lfloor\lg n\rfloor} \left(\frac{n}{2^k}+1\right) \\ diff --git a/appendixa/sections/2/3.tex b/appendixa/sections/2/3.tex index 7084bba..038d52e 100644 --- a/appendixa/sections/2/3.tex +++ b/appendixa/sections/2/3.tex @@ -1,4 +1,3 @@ -\exercise Proceeding similarly as when searching for an upper bound on the $n$th harmonic number, we split the range 1 to $n$ into $\lfloor\lg n\rfloor$ pieces and lower-bound the contribution of each piece by $1/2$: \begin{align*} \sum_{k=1}^n\frac{1}{k} &\ge \sum_{i=0}^{\lfloor\lg n\rfloor-1} \sum_{j=0}^{2^i-1} \frac{1}{2^i+j} \\ diff --git a/appendixa/sections/2/4.tex b/appendixa/sections/2/4.tex index ab87eaf..d19e9cf 100644 --- a/appendixa/sections/2/4.tex +++ b/appendixa/sections/2/4.tex @@ -1,4 +1,3 @@ -\exercise The function $f(k)=k^3$ is monotonically increasing, so we approximate the summation using inequality (A.18): \[ \int_0^n x^3\,dx \le \sum_{k=1}^n k^3 \le \int_1^{n+1} x^3\,dx. diff --git a/appendixa/sections/2/5.tex b/appendixa/sections/2/5.tex index bc235fe..ccbe0d8 100644 --- a/appendixa/sections/2/5.tex +++ b/appendixa/sections/2/5.tex @@ -1,4 +1,3 @@ -\exercise Applying inequality (A.19) to $\sum_{k=1}^n 1/k$ leads to an improper integral: \begin{align*} \sum_{k=1}^n \frac{1}{k} &\le \int_0^n \frac{dx}{x} \\ diff --git a/appendixa/sections/2/main.tex b/appendixa/sections/2/main.tex deleted file mode 100644 index 220df24..0000000 --- a/appendixa/sections/2/main.tex +++ /dev/null @@ -1,6 +0,0 @@ -\section{Bounding summations} -\subimport{./}{1} -\subimport{./}{2} -\subimport{./}{3} -\subimport{./}{4} -\subimport{./}{5} diff --git a/appendixb/main.tex b/appendixb/main.tex deleted file mode 100644 index 5f0afd6..0000000 --- a/appendixb/main.tex +++ /dev/null @@ -1,10 +0,0 @@ -\chapter{Sets, Etc.} -\subimport{sections/1/}{main} -\subimport{sections/2/}{main} -\subimport{sections/3/}{main} -\subimport{sections/4/}{main} -\subimport{sections/5/}{main} -\problems -\subimport{problems/1/}{main} -\subimport{problems/2/}{main} -\subimport{problems/3/}{main} diff --git a/appendixb/problems/1/a.tex b/appendixb/problems/1/a.tex index 5464b7c..4e21e48 100644 --- a/appendixb/problems/1/a.tex +++ b/appendixb/problems/1/a.tex @@ -1,3 +1,2 @@ -\subproblem For a given tree let us distinguish any of its nodes and view the tree as a rooted tree in that node. Edges in such a tree are incident on nodes from adjacent levels, so nodes can be colored according to the parity of their depth in the tree (e.g., those on odd levels get color 1, and those on even levels get color 2). diff --git a/appendixb/problems/1/b.tex b/appendixb/problems/1/b.tex index 0392659..7b64f4e 100644 --- a/appendixb/problems/1/b.tex +++ b/appendixb/problems/1/b.tex @@ -1,4 +1,3 @@ -\subproblem $(1)\Rightarrow(2)$: Since $G=(V,E)$ is a bipartite graph, the vertex set $V$ can be partitioned into two subsets $V_1$ and $V_2$, such that vertices from one subset aren't adjacent to vertices from the other subset. Thanks to this property it is possible to assign one color to each vertex from $V_1$ and a different color to each vertex from $V_2$, obtaining a 2-coloring of graph $G$. diff --git a/appendixb/problems/1/c.tex b/appendixb/problems/1/c.tex index b1c6ed6..3570c76 100644 --- a/appendixb/problems/1/c.tex +++ b/appendixb/problems/1/c.tex @@ -1,4 +1,3 @@ -\subproblem We carry out the proof by induction on the number of vertices in graph $G=(V,E)$. If the graph has only one vertex (with degree 0), then of course one color is enough. diff --git a/appendixb/problems/1/d.tex b/appendixb/problems/1/d.tex index a68c41a..525f513 100644 --- a/appendixb/problems/1/d.tex +++ b/appendixb/problems/1/d.tex @@ -1,4 +1,3 @@ -\subproblem For any $k\ge2$, if graph $G$ is $k$-colorable, but is not $(k-1)$-colorable, then for every two different colors used in a $k$-coloring of $G$ there are two adjacent vertices, one with the first color and the other with the second color. If that weren't true, there would be two different colors that we could not distinguish, and so we could reduce the number of colors required, obtaining a $(k-1)$-coloring of $G$. diff --git a/appendixb/problems/1/main.tex b/appendixb/problems/1/main.tex deleted file mode 100644 index c6d7e58..0000000 --- a/appendixb/problems/1/main.tex +++ /dev/null @@ -1,5 +0,0 @@ -\problem{Graph coloring} -\subimport{./}{a} -\subimport{./}{b} -\subimport{./}{c} -\subimport{./}{d} diff --git a/appendixb/problems/2/a.tex b/appendixb/problems/2/a.tex index 0d19612..9e1eedb 100644 --- a/appendixb/problems/2/a.tex +++ b/appendixb/problems/2/a.tex @@ -1,4 +1,3 @@ -\subproblem \begin{theorem} In any undirected graph $G=(V,E)$, where $|V|\ge2$, there are two vertices with the same degree. \end{theorem} diff --git a/appendixb/problems/2/b.tex b/appendixb/problems/2/b.tex index 0076c93..ff4f0cb 100644 --- a/appendixb/problems/2/b.tex +++ b/appendixb/problems/2/b.tex @@ -1,4 +1,3 @@ -\subproblem \begin{theorem} An undirected graph $G=(V,E)$ of 6 vertices, or its complement\footnote{See page 1085 in the book.} $\overline{G}$, contain a clique\footnote{See page 1081 in the book.} of size 3. \end{theorem} diff --git a/appendixb/problems/2/c.tex b/appendixb/problems/2/c.tex index bec5efc..5df550c 100644 --- a/appendixb/problems/2/c.tex +++ b/appendixb/problems/2/c.tex @@ -1,4 +1,3 @@ -\subproblem \begin{theorem} For any undirected graph $G=(V,E)$ the set $V$ can be partitioned into two subsets such that for any vertex $v\in V$ at least half of its neighbors do not belong to the subset that $v$ belongs to. \end{theorem} diff --git a/appendixb/problems/2/d.tex b/appendixb/problems/2/d.tex index 749e734..8dd39bc 100644 --- a/appendixb/problems/2/d.tex +++ b/appendixb/problems/2/d.tex @@ -1,4 +1,3 @@ -\subproblem Before we formulate the main theorem, we will need the following lemma. \begin{lemma} Let $G=(V,E)$ be an undirected graph, where $|V|\ge3$ and diff --git a/appendixb/problems/2/main.tex b/appendixb/problems/2/main.tex deleted file mode 100644 index 7968fd4..0000000 --- a/appendixb/problems/2/main.tex +++ /dev/null @@ -1,5 +0,0 @@ -\problem{Friendly graphs} -\subimport{./}{a} -\subimport{./}{b} -\subimport{./}{c} -\subimport{./}{d} diff --git a/appendixb/problems/3/a.tex b/appendixb/problems/3/a.tex index e36661d..343df91 100644 --- a/appendixb/problems/3/a.tex +++ b/appendixb/problems/3/a.tex @@ -1,4 +1,3 @@ -\subproblem The fact trivially holds for binary trees with at most three nodes, so in the rest of the proof we will assume that $n\ge4$. We define a \concept{branch} of a binary tree as a path $\langle x_0$, $x_1$, \dots, $x_k\rangle$, where $x_0$ is the root, $x_k$ is a leaf, and for $i=1$, 2, \dots, $k$, $x_i$ is the root of the subtree of $x_{i-1}$ with more nodes. Note that a tree may have more than one branch. diff --git a/appendixb/problems/3/b.tex b/appendixb/problems/3/b.tex index 16ab63f..02112b0 100644 --- a/appendixb/problems/3/b.tex +++ b/appendixb/problems/3/b.tex @@ -1,7 +1,6 @@ -\subproblem The constant $3/4$ is sufficient to make balanced partitions, as we have shown in part (a). The example of the binary tree in \refFigure{B-3b} shows that the constant cannot be lower. \begin{figure}[htb] - \subimport{./}{b.tikz} + \input{b.tikz} \caption{The binary tree whose most evenly balanced partition upon removal of a single edge has a subset with 3 vertices.} \label{fig:B-3b} \end{figure} diff --git a/appendixb/problems/3/c.tex b/appendixb/problems/3/c.tex index e67339f..498d938 100644 --- a/appendixb/problems/3/c.tex +++ b/appendixb/problems/3/c.tex @@ -1,4 +1,3 @@ -\subproblem Assume that $n\ge6$. We'll remove one edge from the original tree to cut off a subtree of at most $\lfloor n/2\rfloor$ vertices. Consider any of the tree's branches $\langle x_0$, $x_1$, \dots, $x_k\rangle$, as well as the function $s$, both defined in the solution to part (a). diff --git a/appendixb/problems/3/main.tex b/appendixb/problems/3/main.tex deleted file mode 100644 index a813d41..0000000 --- a/appendixb/problems/3/main.tex +++ /dev/null @@ -1,4 +0,0 @@ -\problem{Bisecting trees} -\subimport{./}{a} -\subimport{./}{b} -\subimport{./}{c} diff --git a/appendixb/sections/1/1.tex b/appendixb/sections/1/1.tex index b6fad81..928640a 100644 --- a/appendixb/sections/1/1.tex +++ b/appendixb/sections/1/1.tex @@ -1,6 +1,5 @@ -\exercise See \refFigure{B.1-1}. \begin{figure}[htb] - \subimport{./}{1.tikz} + \input{1.tikz} \caption{A Venn diagram illustrating the first of the distributive laws (B.1).} \label{fig:B.1-1} \end{figure} diff --git a/appendixb/sections/1/2.tex b/appendixb/sections/1/2.tex index 1444e90..504d109 100644 --- a/appendixb/sections/1/2.tex +++ b/appendixb/sections/1/2.tex @@ -1,4 +1,3 @@ -\exercise We prove the first formula by induction on $n$. For $n=1$ the proof is trivial, and for $n=2$ the formula is the first of DeMorgan's laws. Let's assume that $n>2$, and that the formula holds for a family of $n-1$ sets. diff --git a/appendixb/sections/1/3.tex b/appendixb/sections/1/3.tex index ca916a5..87e11d1 100644 --- a/appendixb/sections/1/3.tex +++ b/appendixb/sections/1/3.tex @@ -1,4 +1,3 @@ -\exercise We prove the principle of inclusion and exclusion by induction on $n$. For $n=1$ the proof is trivial, and for $n=2$ the formula is identical to (B.3). If $n>2$, then by (B.3) and the generalized first distributive law, we have: diff --git a/appendixb/sections/1/4.tex b/appendixb/sections/1/4.tex index ab56d81..cd8b7ef 100644 --- a/appendixb/sections/1/4.tex +++ b/appendixb/sections/1/4.tex @@ -1,3 +1,2 @@ -\exercise An example of a one-to-one correspondence between $\mathbb{N}$ and the set of odd natural numbers is: $n \to 2n+1$. Thus, the set of odd natural numbers is countable. diff --git a/appendixb/sections/1/5.tex b/appendixb/sections/1/5.tex index 37d2ee4..a18f219 100644 --- a/appendixb/sections/1/5.tex +++ b/appendixb/sections/1/5.tex @@ -1,4 +1,3 @@ -\exercise We prove by induction on the cardinality of the set $S$. When $|S|=0$, it holds that $|2^S|=2^{|S|}=1$, because $S$ has exactly one subset\dash the empty set. diff --git a/appendixb/sections/1/6.tex b/appendixb/sections/1/6.tex index f66d9e0..824b47d 100644 --- a/appendixb/sections/1/6.tex +++ b/appendixb/sections/1/6.tex @@ -1,4 +1,3 @@ -\exercise An $n$-tuple of elements $a_1$, $a_2$, \dots, $a_n$ is defined as: \[ (a_1,a_2,\dots,a_n) = diff --git a/appendixb/sections/1/main.tex b/appendixb/sections/1/main.tex deleted file mode 100644 index de3a8ac..0000000 --- a/appendixb/sections/1/main.tex +++ /dev/null @@ -1,7 +0,0 @@ -\section{Sets} -\subimport{./}{1} -\subimport{./}{2} -\subimport{./}{3} -\subimport{./}{4} -\subimport{./}{5} -\subimport{./}{6} diff --git a/appendixb/sections/2/1.tex b/appendixb/sections/2/1.tex index 2bbc98d..7770154 100644 --- a/appendixb/sections/2/1.tex +++ b/appendixb/sections/2/1.tex @@ -1,4 +1,3 @@ -\exercise To show that the relation ``$\subseteq$'' on the power set $2^\mathbb{Z}$ is a partial order, we will show that ``$\subseteq$'' is reflexive, antisymmetric and transitive. Let $A$, $B$, $C\in2^\mathbb{Z}$. Of course, $x\in A$ implies $x\in A$, so reflexivity trivially holds. diff --git a/appendixb/sections/2/2.tex b/appendixb/sections/2/2.tex index 5a3c633..2177b10 100644 --- a/appendixb/sections/2/2.tex +++ b/appendixb/sections/2/2.tex @@ -1,4 +1,3 @@ -\exercise Let us denote the relation ``equivalent modulo $n$'', for $n\in\mathbb{N}-\{0\}$, by \[ R_n = \{(a,b)\in\mathbb{Z}\times\mathbb{Z}: a=b\!\!\!\pmod{n}\}. diff --git a/appendixb/sections/2/3.tex b/appendixb/sections/2/3.tex index ab76ef3..d2499c4 100644 --- a/appendixb/sections/2/3.tex +++ b/appendixb/sections/2/3.tex @@ -1,4 +1,3 @@ -\exercise \subexercise The relation $\{(a,a),(b,b),(c,c),(a,b),(b,a),(a,c),(c,a)\}$ on the set $\{a,b,c\}$. diff --git a/appendixb/sections/2/4.tex b/appendixb/sections/2/4.tex index be4e732..9434a03 100644 --- a/appendixb/sections/2/4.tex +++ b/appendixb/sections/2/4.tex @@ -1,4 +1,3 @@ -\exercise If $R$ is an equivalence relation, then $s\in[s]$ for all $s\in S$. By antisymmetry of $R$, if $s'\,R\,s$ and $s\,R\,s'$, then $s=s'$, so there are no such $s'$ that $s'\in[s]-\{s\}$. This means that for all $s\in S$, $[s]=\{s\}$. diff --git a/appendixb/sections/2/5.tex b/appendixb/sections/2/5.tex index bbca548..8756cb2 100644 --- a/appendixb/sections/2/5.tex +++ b/appendixb/sections/2/5.tex @@ -1,4 +1,3 @@ -\exercise Symmetry and transitivity are defined using implications. For an implication ``$p$ implies $q$'' to hold true, it isn’t required for $p$ to be true. A relation on a set remains symmetric and transitive, if there is an element in the set, that is not related to any element in that set. diff --git a/appendixb/sections/2/main.tex b/appendixb/sections/2/main.tex deleted file mode 100644 index d7be857..0000000 --- a/appendixb/sections/2/main.tex +++ /dev/null @@ -1,6 +0,0 @@ -\section{Relations} -\subimport{./}{1} -\subimport{./}{2} -\subimport{./}{3} -\subimport{./}{4} -\subimport{./}{5} diff --git a/appendixb/sections/3/1.tex b/appendixb/sections/3/1.tex index e3bf1e7..85d5fcf 100644 --- a/appendixb/sections/3/1.tex +++ b/appendixb/sections/3/1.tex @@ -1,4 +1,3 @@ -\exercise \subexercise For any function $f:A\to B$, $f(A)\subseteq B$, which results directly from the definition of the range of $f$\!. Additionally, if $f$ is injective, then each argument $a\in A$ has a distinct image $f(a)\in f(A)$, so $|A|=|f(A)|$. diff --git a/appendixb/sections/3/2.tex b/appendixb/sections/3/2.tex index 5144d13..a395824 100644 --- a/appendixb/sections/3/2.tex +++ b/appendixb/sections/3/2.tex @@ -1,3 +1,2 @@ -\exercise The function $f(x)=x+1$, with $\mathbb{N}$ as both the domain and the codomain, is not bijective because there is no $x\in\mathbb{N}$ such that $f(x)=0$. If we consider $\mathbb{Z}$ as the domain and the codomain, then $f$ becomes bijective, since every integer $y$ in the codomain is an image under $f$ of a uniquely determined integer in the domain: $y=f(y-1)$. diff --git a/appendixb/sections/3/3.tex b/appendixb/sections/3/3.tex index 88ad6ec..cec5b28 100644 --- a/appendixb/sections/3/3.tex +++ b/appendixb/sections/3/3.tex @@ -1,4 +1,3 @@ -\exercise The definition comes as a natural generalization of the functional inverse. Let $R$ be a binary relation on sets $A$ an $B$. The binary relation $R^{-1}$ on sets $B$ and $A$, such that diff --git a/appendixb/sections/3/4.tex b/appendixb/sections/3/4.tex index ebe86bb..a27bc05 100644 --- a/appendixb/sections/3/4.tex +++ b/appendixb/sections/3/4.tex @@ -1,4 +1,3 @@ -\exercise Let $h:\mathbb{Z}\to\mathbb{Z}\times\mathbb{Z}$ be the function we are looking for. Since the inverse of a bijection is also a bijection, we will focus on finding the inverse $h^{-1}:\mathbb{Z}\times\mathbb{Z}\to\mathbb{Z}$, which is equivalent to finding a way to sequentially number each ordered pair with integer elements, so that each integer is used as the number of some pair. We will now describe the construction of one of such mappings. @@ -10,7 +9,7 @@ Consider the numbering of ordered pairs with integer elements shown in \refFigure{B.3-4} in the form of a spiral. Since each such pair $(x,y)$ is assigned a unique natural number, we can treat this spiral as a description of the function $g$. \begin{figure}[htb] - \subimport{./}{4.tikz} + \input{4.tikz} \caption{A bijection from $\mathbb{Z}\times\mathbb{Z}$ to $\mathbb{Z}$. Individual natural numbers denote the values of this bijection for points with integer coordinates in the Cartesian coordinate system. } \label{fig:B.3-4} diff --git a/appendixb/sections/3/main.tex b/appendixb/sections/3/main.tex deleted file mode 100644 index 0830cdc..0000000 --- a/appendixb/sections/3/main.tex +++ /dev/null @@ -1,5 +0,0 @@ -\section{Functions} -\subimport{./}{1} -\subimport{./}{2} -\subimport{./}{3} -\subimport{./}{4} diff --git a/appendixb/sections/4/1.tex b/appendixb/sections/4/1.tex index 5ff5474..eae2d8f 100644 --- a/appendixb/sections/4/1.tex +++ b/appendixb/sections/4/1.tex @@ -1,3 +1,2 @@ -\exercise We can represent the relation of ``shaking hands'' on the faculty party as an undirected graph $G=(V,E)$, where $V$ is the set of professors attending the party and $E$ is the set of unordered pairs of professors who shook hands. Summing up the degrees of all vertices of $G$, we get twice the number of its edges, because each edge is incident on exactly two vertices. diff --git a/appendixb/sections/4/2.tex b/appendixb/sections/4/2.tex index 8e65dbf..8168b0c 100644 --- a/appendixb/sections/4/2.tex +++ b/appendixb/sections/4/2.tex @@ -1,4 +1,3 @@ -\exercise Let $\langle v_0$, $v_1$, \dots, $v_n\rangle$ be a path from vertex $u$ to vertex $v$ in a directed or undirected graph. If the path is simple, the vertices in the path are distinct. Otherwise, the path contains a cycle $\langle v_i$, $v_{i+1}$, \dots, $v_{i+k}$, $v_i\rangle$ for some $i$ and $k$, and by eliminating the subpath $\langle v_i$, $v_{i+1}$, \dots, $v_{i+k}\rangle$ from the path, we discard an extra repetition of $v_i$. diff --git a/appendixb/sections/4/3.tex b/appendixb/sections/4/3.tex index 065d6e9..78d8125 100644 --- a/appendixb/sections/4/3.tex +++ b/appendixb/sections/4/3.tex @@ -1,4 +1,3 @@ -\exercise We proceed by induction on the number of vertices in the graph $G=(V,E)$. When $|V|=1$, the graph has no edges and the inequality trivially holds. For the inductive step, pick a vertex $v\in V$. diff --git a/appendixb/sections/4/4.tex b/appendixb/sections/4/4.tex index fb2f359..7780e48 100644 --- a/appendixb/sections/4/4.tex +++ b/appendixb/sections/4/4.tex @@ -1,4 +1,3 @@ -\exercise Every vertex of a directed or undirected graph is reachable from itself because there is a path of length 1 containing only that vertex, therefore the ``is reachable from'' relation is reflexive. Let $u$, $v$, $w$ be vertices of a directed or undirected graph such that $u\overset{p}{\leadsto}v$ and $v\overset{q}{\leadsto}w$. diff --git a/appendixb/sections/4/5.tex b/appendixb/sections/4/5.tex index fa7e8ad..09cb80f 100644 --- a/appendixb/sections/4/5.tex +++ b/appendixb/sections/4/5.tex @@ -1,8 +1,7 @@ -\exercise See \refFigure{B.4-5}. \begin{figure}[htb] - \subcaptionbox{\label{fig:B.4-5a}}[0.45\textwidth]{\subimport{./}{5a.tikz}} - \subcaptionbox{\label{fig:B.4-5b}}[0.45\textwidth]{\subimport{./}{5b.tikz}} + \subcaptionbox{\label{fig:B.4-5a}}[0.45\textwidth]{\input{5a.tikz}} + \subcaptionbox{\label{fig:B.4-5b}}[0.45\textwidth]{\input{5b.tikz}} \caption{\textbf{(a)}\, The undirected version of the directed graph in Figure B.2(a).\, \textbf{(b)}\, The directed version of the undirected graph in Figure B.2(b).} \label{fig:B.4-5} \end{figure} diff --git a/appendixb/sections/4/6.tex b/appendixb/sections/4/6.tex index 40fb095..6e86e74 100644 --- a/appendixb/sections/4/6.tex +++ b/appendixb/sections/4/6.tex @@ -1,4 +1,3 @@ -\exercise A hypergraph $H=(V_H,E_H)$ can be represented as a bipartite graph $G=(V_1\cup V_2,E)$, where $V_1=V_H$ and $V_2=E_H$. A pair $\{v_1,v_2\}$, such that $v_1\in V_1$ and $v_2\in V_2$, is an edge of the graph $G$, if and only if the hyperedge $v_2$ is incident on vertex $v_1$ in the hypergraph $H$. In the graph $G$ there are no edges between elements of $V_1$ or between elements of $V_2$, so $G$ is indeed bipartite. diff --git a/appendixb/sections/4/main.tex b/appendixb/sections/4/main.tex deleted file mode 100644 index 3768321..0000000 --- a/appendixb/sections/4/main.tex +++ /dev/null @@ -1,7 +0,0 @@ -\section{Graphs} -\subimport{./}{1} -\subimport{./}{2} -\subimport{./}{3} -\subimport{./}{4} -\subimport{./}{5} -\subimport{./}{6} diff --git a/appendixb/sections/5/1.tex b/appendixb/sections/5/1.tex index a10a4a9..7ec0258 100644 --- a/appendixb/sections/5/1.tex +++ b/appendixb/sections/5/1.tex @@ -1,10 +1,9 @@ -\exercise See \refFigure{B.5-1}. \begin{figure}[htb] - \subcaptionbox{\label{fig:B.5-1a}}[0.15\textwidth]{\subimport{./}{1a.tikz}} - \subcaptionbox{\label{fig:B.5-1b}}[0.25\textwidth]{\subimport{./}{1b.tikz}} - \subcaptionbox{\label{fig:B.5-1c}}[0.35\textwidth]{\subimport{./}{1c.tikz}} - \subcaptionbox{\label{fig:B.5-1d}}[0.8\textwidth]{\subimport{./}{1d.tikz}} + \subcaptionbox{\label{fig:B.5-1a}}[0.15\textwidth]{\input{1a.tikz}} + \subcaptionbox{\label{fig:B.5-1b}}[0.25\textwidth]{\input{1b.tikz}} + \subcaptionbox{\label{fig:B.5-1c}}[0.35\textwidth]{\input{1c.tikz}} + \subcaptionbox{\label{fig:B.5-1d}}[0.8\textwidth]{\input{1d.tikz}} \caption{\textbf{(a)}\, All the free trees with vertices $x$, $y$, and $z$.\, \textbf{(b)}\, All the rooted trees with nodes $x$, $y$, and $z$ with $x$ as the root.\, \textbf{(c)}\, All the ordered trees with nodes $x$, $y$, and $z$ with $x$ as the root.\, diff --git a/appendixb/sections/5/2.tex b/appendixb/sections/5/2.tex index da05230..830d5eb 100644 --- a/appendixb/sections/5/2.tex +++ b/appendixb/sections/5/2.tex @@ -1,4 +1,3 @@ -\exercise Let $G'=(V,E')$ be the undirected version of the graph $G$. Note that $G'$ is connected, since every vertex $v\in V$ is reachable from vertex $v_0$ in $G'$. diff --git a/appendixb/sections/5/3.tex b/appendixb/sections/5/3.tex index 5af17b4..ccbcc85 100644 --- a/appendixb/sections/5/3.tex +++ b/appendixb/sections/5/3.tex @@ -1,4 +1,3 @@ -\exercise The proof is by induction on the number $n$ of nodes in the tree. The base case is when $n=1$. A binary tree with only one node has one leaf and no degree-2 nodes, thus the statement holds. diff --git a/appendixb/sections/5/4.tex b/appendixb/sections/5/4.tex index 0a47c9c..7079006 100644 --- a/appendixb/sections/5/4.tex +++ b/appendixb/sections/5/4.tex @@ -1,4 +1,3 @@ -\exercise We construct a sequence of full binary trees $T_1$, $T_2$, \dots, as follows. Let $T_1$ be a binary tree containing a single node, which obviously is a single leaf. For any $k\ge2$, let $T_k$ be a binary tree whose left subtree is $T_{k-1}$ and whose right subtree is a one-node binary tree. diff --git a/appendixb/sections/5/5.tex b/appendixb/sections/5/5.tex index 3ad0fed..df94709 100644 --- a/appendixb/sections/5/5.tex +++ b/appendixb/sections/5/5.tex @@ -1,4 +1,3 @@ -\exercise The proof is by induction on the height $h$ of the binary tree. The only nonempty binary tree with $h=0$ is the one with a single node, so $n=1$ and the statement $h\ge\lfloor\lg n\rfloor$ holds. diff --git a/appendixb/sections/5/6.tex b/appendixb/sections/5/6.tex index 6930d7d..341978f 100644 --- a/appendixb/sections/5/6.tex +++ b/appendixb/sections/5/6.tex @@ -1,4 +1,3 @@ -\exercise We proceed by induction on $n$. The base case is when $n=0$. The only full binary tree that has no internal nodes is a one-node tree, for which we have $e=i=0$ and the statement holds. diff --git a/appendixb/sections/5/7.tex b/appendixb/sections/5/7.tex index 99d0381..ed8ff3c 100644 --- a/appendixb/sections/5/7.tex +++ b/appendixb/sections/5/7.tex @@ -1,4 +1,3 @@ -\exercise The proof is by induction on the number $n$ of nodes of the tree. In the empty tree (where $n=0$) the sum of the leaf weights is 0, which obviously satisfies the inequality. When $n=1$, then the tree consists of a single leaf with a depth of 0, so the sum of the leaf weights is $2^{-0}=1$. diff --git a/appendixb/sections/5/8.tex b/appendixb/sections/5/8.tex index 81131b6..ea8d3c9 100644 --- a/appendixb/sections/5/8.tex +++ b/appendixb/sections/5/8.tex @@ -1,4 +1,3 @@ -\exercise Let $T$ be a binary tree with $L\ge2$ leaves. Suppose that $T$ does not contain a subtree having between $L/3$ and $2L/3$ leaves, inclusive. Since $L\ge2$, the root of $T$ is not a leaf. diff --git a/appendixb/sections/5/main.tex b/appendixb/sections/5/main.tex deleted file mode 100644 index 05da359..0000000 --- a/appendixb/sections/5/main.tex +++ /dev/null @@ -1,9 +0,0 @@ -\section{Trees} -\subimport{./}{1} -\subimport{./}{2} -\subimport{./}{3} -\subimport{./}{4} -\subimport{./}{5} -\subimport{./}{6} -\subimport{./}{7} -\subimport{./}{8} diff --git a/clrs4e-solutions.tex b/clrs4e-solutions.tex index 972ad9c..fba23b3 100644 --- a/clrs4e-solutions.tex +++ b/clrs4e-solutions.tex @@ -172,6 +172,32 @@ \DeclareMathOperator{\degree}{degree} +\newcommand{\MakeChapter}[4]{% + \chapter{#1}% + \foreach \Title [count=\Section] in {#2}{% + \section{\Title} + \foreach \Exercise in {1,...,16}{% + \IfFileExists{#4/sections/\Section/\Exercise}{% + \exercise + \import{#4/sections/\Section/}{\Exercise} + }{}% + }% + }% + \problems + \foreach \Title [count=\Problem] in {#3}{% + \problem{\Title} + \IfFileExists{#4/problems/\Problem/main}{% + \import{#4/problems/\Problem/}{main} + }{}% + \foreach \SubProblem in {a,...,j}{% + \IfFileExists{#4/problems/\Problem/\SubProblem}{% + \subproblem + \import{#4/problems/\Problem/}{\SubProblem} + }{}% + }% + }% +} + \usetikzlibrary{ arrows.meta, bending, @@ -207,8 +233,20 @@ \part{Appendix: Mathematical Background} \appendix - \import{appendixa/}{main} - \import{appendixb/}{main} + \MakeChapter{Summations}{ + Summation formulas and properties, + Bounding summations}{ + Bounding summations}{appendixa} + + \MakeChapter{Sets, Etc.}{ + Sets, + Relations, + Functions, + Graphs, + Trees}{ + Graph coloring, + Friendly graphs, + Bisecting trees}{appendixb} \backmatter