Skip to content

Commit

Permalink
#236 migrate 6.4-1
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtask committed Oct 2, 2024
1 parent 21c9634 commit 348bb79
Show file tree
Hide file tree
Showing 12 changed files with 200 additions and 1 deletion.
25 changes: 24 additions & 1 deletion chapter6/sections/4/1.tex
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
\workinprogress % TODO
See \refFigure{6.4-1}.
\begin{figure}[htb]
\hspace*{-1.5cm}
\begin{minipage}{\textwidth + 1.5cm}
\captionsetup[subfigure]{}
\subcaptionbox{\label{fig:6.4-1a}}[0.33\textwidth]{\input{1a.tikz}}
\subcaptionbox{\label{fig:6.4-1b}}[0.33\textwidth]{\input{1b.tikz}}
\subcaptionbox{\label{fig:6.4-1c}}[0.33\textwidth]{\input{1c.tikz}}
\par\vspace{3ex}
\subcaptionbox{\label{fig:6.4-1d}}[0.33\textwidth]{\input{1d.tikz}}
\subcaptionbox{\label{fig:6.4-1e}}[0.33\textwidth]{\input{1e.tikz}}
\subcaptionbox{\label{fig:6.4-1f}}[0.33\textwidth]{\input{1f.tikz}}
\par\vspace{3ex}
\subcaptionbox{\label{fig:6.4-1g}}[0.33\textwidth]{\input{1g.tikz}}
\subcaptionbox{\label{fig:6.4-1h}}[0.33\textwidth]{\input{1h.tikz}}
\subcaptionbox{\label{fig:6.4-1i}}[0.33\textwidth]{\input{1i.tikz}}
\par\vspace{3ex}
\subcaptionbox{\label{fig:6.4-1j}}[0.33\textwidth]{\input{1j.tikz}}
\end{minipage}
\caption{The operation of \proc{Heapsort} on the array $A=\langle$5, 13, 2, 25, 7, 17, 20, 8, 4$\rangle$.\,
\textbf{(a)}\, The max-heap built by \proc{Build-Max-Heap} in line 1.\,
\textbf{(b)--(i)}\, The max-heap and the nodes removed from it after each call to \proc{Max-Heapify} in line 5.\,
\textbf{(j)}\, The resulting sorted array $A$.} \label{fig:6.4-1}
\end{figure}
7 changes: 7 additions & 0 deletions chapter6/sections/4/1.tikz
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
\setlength{\vertexsize}{1.1em}
\tikzset{
every node/.style = {light blue vertex},
discarded/.style = {tan vertex},
every label/.style = {index},
level/.append style = {sibling distance=5\vertexsize/#1},
}
18 changes: 18 additions & 0 deletions chapter6/sections/4/1a.tikz
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
\input{1.tikz}
\begin{tikzpicture}
\node {25}
child {node {13}
child {node {8}
child {node {5}}
child {node {4}}
}
child {node {7}}
}
child {node {20}
child {node {17}}
child {node {2}
child[missing]
child {node[draw=none, fill=none] {} edge from parent[draw=none]}
}
};
\end{tikzpicture}
18 changes: 18 additions & 0 deletions chapter6/sections/4/1b.tikz
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
\input{1.tikz}
\begin{tikzpicture}
\node {20}
child {node {13}
child {node {8}
child {node {5}}
child {node[discarded, label=right:{$i$}] {25} edge from parent[draw=none]}
}
child {node {7}}
}
child {node {17}
child {node {4}}
child {node {2}
child[missing]
child {node[draw=none, fill=none] {} edge from parent[draw=none]}
}
};
\end{tikzpicture}
18 changes: 18 additions & 0 deletions chapter6/sections/4/1c.tikz
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
\input{1.tikz}
\begin{tikzpicture}
\node {17}
child {node {13}
child {node {8}
child {node[discarded, label=left:{$i$}] {20} edge from parent[draw=none]}
child {node[discarded] {25} edge from parent[draw=none]}
}
child {node {7}}
}
child {node {5}
child {node {4}}
child {node {2}
child[missing]
child {node[draw=none, fill=none, label=right:{}] {} edge from parent[draw=none]}
}
};
\end{tikzpicture}
18 changes: 18 additions & 0 deletions chapter6/sections/4/1d.tikz
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
\input{1.tikz}
\begin{tikzpicture}
\node {13}
child {node {8}
child {node {2}
child {node[discarded] {20} edge from parent[draw=none]}
child {node[discarded] {25} edge from parent[draw=none]}
}
child {node {7}}
}
child {node {5}
child {node {4}}
child {node[discarded, label=left:{$i$}] {17} edge from parent[draw=none]
child[missing]
child {node[draw=none, fill=none] {} edge from parent[draw=none]}
}
};
\end{tikzpicture}
18 changes: 18 additions & 0 deletions chapter6/sections/4/1e.tikz
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
\input{1.tikz}
\begin{tikzpicture}
\node {8}
child {node {7}
child {node {2}
child {node[discarded] {20} edge from parent[draw=none]}
child {node[discarded] {25} edge from parent[draw=none]}
}
child {node {4}}
}
child {node {5}
child {node[discarded, label=left:{$i$}] {13} edge from parent[draw=none]}
child {node[discarded] {17} edge from parent[draw=none]
child[missing]
child {node[draw=none, fill=none] {} edge from parent[draw=none]}
}
};
\end{tikzpicture}
18 changes: 18 additions & 0 deletions chapter6/sections/4/1f.tikz
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
\input{1.tikz}
\begin{tikzpicture}
\node {7}
child {node {4}
child {node {2}
child {node[discarded] {20} edge from parent[draw=none]}
child {node[discarded] {25} edge from parent[draw=none]}
}
child {node[discarded, label=left:{$i$}] {8} edge from parent[draw=none]}
}
child {node {5}
child {node[discarded] {13} edge from parent[draw=none]}
child {node[discarded] {17} edge from parent[draw=none]
child[missing]
child {node[draw=none, fill=none] {} edge from parent[draw=none]}
}
};
\end{tikzpicture}
18 changes: 18 additions & 0 deletions chapter6/sections/4/1g.tikz
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
\input{1.tikz}
\begin{tikzpicture}
\node {5}
child {node {4}
child {node[discarded, label=left:{$i$}] {7} edge from parent[draw=none]
child {node[discarded] {20} edge from parent[draw=none]}
child {node[discarded] {25} edge from parent[draw=none]}
}
child {node[discarded] {8} edge from parent[draw=none]}
}
child {node {2}
child {node[discarded] {13} edge from parent[draw=none]}
child {node[discarded] {17} edge from parent[draw=none]
child[missing]
child {node[draw=none, fill=none] {} edge from parent[draw=none]}
}
};
\end{tikzpicture}
18 changes: 18 additions & 0 deletions chapter6/sections/4/1h.tikz
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
\input{1.tikz}
\begin{tikzpicture}
\node {4}
child {node {2}
child {node[discarded] {7} edge from parent[draw=none]
child {node[discarded] {20} edge from parent[draw=none]}
child {node[discarded] {25} edge from parent[draw=none]}
}
child {node[discarded] {8} edge from parent[draw=none]}
}
child {node[discarded, label=left:{$i$}] {5} edge from parent[draw=none]
child {node[discarded] {13} edge from parent[draw=none]}
child {node[discarded] {17} edge from parent[draw=none]
child[missing]
child {node[draw=none, fill=none] {} edge from parent[draw=none]}
}
};
\end{tikzpicture}
18 changes: 18 additions & 0 deletions chapter6/sections/4/1i.tikz
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
\input{1.tikz}
\begin{tikzpicture}
\node {2}
child {node[discarded, label=left:{$i$}] {4} edge from parent[draw=none]
child {node[discarded] {7} edge from parent[draw=none]
child {node[discarded] {20} edge from parent[draw=none]}
child {node[discarded] {25} edge from parent[draw=none]}
}
child {node[discarded] {8} edge from parent[draw=none]}
}
child {node[discarded] {5} edge from parent[draw=none]
child {node[discarded] {13} edge from parent[draw=none]}
child {node[discarded] {17} edge from parent[draw=none]
child[missing]
child {node[draw=none, fill=none] {} edge from parent[draw=none]}
}
};
\end{tikzpicture}
7 changes: 7 additions & 0 deletions chapter6/sections/4/1j.tikz
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
\input{1.tikz}
\begin{tikzpicture}[
every node/.style = {},
]
\matrix[array, row 1/.append style={nodes={fill=tan}}, label=left:{$A$}] {
2 & 4 & 5 & 7 & 8 & 13 & 17 & 20 & 25 \\};
\end{tikzpicture}

0 comments on commit 348bb79

Please sign in to comment.