diff --git a/Notes/TIKZ/determinant-algo-slow.tikz b/Notes/TIKZ/determinant-algo-slow.tikz new file mode 100644 index 0000000..115db40 --- /dev/null +++ b/Notes/TIKZ/determinant-algo-slow.tikz @@ -0,0 +1,27 @@ + +\begin{tikzpicture}[ + level distance=2cm, + level 1/.style={->, sibling distance=4cm}, + level 2/.style={->, sibling distance=2cm}, + every node/.style={align=center} +] + +\node {$\left[\begin{array}{ccc} 3 & 7 & 5 \\ 2 & 9 & 8 \\ 1 & 3 & 3 \end{array}\right]$} +child { + node {$\left[\begin{array}{cc} 3 & 8 \\ 3 & 3 \end{array}\right]$} + child { node {$[3]$} } + child { node {$[3]$} } +} +child { + node {$\left[\begin{array}{cc} 2 & 8 \\ 1 & 3 \end{array}\right]$} + child { node {$[3]$} } + child { node {$[1]$} } +} +child { + node {$\left[\begin{array}{cc} 2 & 9 \\ 1 & 3 \end{array}\right]$} + child { node {$[3]$} } + child { node {$[1]$} } +}; + +\end{tikzpicture} + diff --git a/Notes/TIKZ/echelon-gaussian-elimination.tikz b/Notes/TIKZ/echelon-gaussian-elimination.tikz new file mode 100644 index 0000000..8540891 --- /dev/null +++ b/Notes/TIKZ/echelon-gaussian-elimination.tikz @@ -0,0 +1,75 @@ +\begin{tikzpicture}[scale=0.6] + +% Colors +\definecolor{mypurple}{RGB}{170,110,200} +\definecolor{myred}{RGB}{210,120,140} +\definecolor{myblue}{RGB}{0,150,180} + +\definecolor{green}{RGB}{0,140,0} + +\draw[thick, green] + (2,-0.5) -- (6.3,-0.5) -- (6.3 ,1) + -- (6.3,1) + -- (6.3,1.8) + -- (4.8,1.8) + -- (4.8,2.6) + -- (3.3,2.6) + -- (3.3,3.4) + -- (2,3.4) + -- cycle; + +\node[green] at (3,1.2) {$0$'s only}; + +\draw[thick, myblue] + (2,4.2) + -- (6.3 ,4.2) + -- (6.3,2) + -- (5,2) + -- (5,2.8) + -- (3.5,2.8) + -- (3.5,3.6) + -- (2,3.6) + -- (2,4.2); + + + +\draw[thick, myred] + (6.5, 4.2) + -- (10, 4.2) + -- (10, 2) + -- (6.5, 2) + -- (6.5, 4.2); + +\draw[thick, mypurple] + (6.5, 1.8) + -- (10, 1.8) + -- (10, -0.5) + -- (6.5, -0.5) + -- (6.5, 1.8); +% Red X marks +\foreach \x/\y in { + 2.3/3.9, + 3.8/3.1, + 5.3/2.3 +}{ + \draw[red, thick] (\x-0.15,\y-0.15) -- (\x+0.15,\y+0.15); + \draw[red, thick] (\x-0.15,\y+0.15) -- (\x+0.15,\y-0.15); +} + +% "Nonzero" label +\node[red] at (3.5,6) {Nonzero}; + +% Red arrows +\draw[red, ->, thick] (3.1,5.8) to[out=-150,in=90] (2.3,4.25); +\draw[red, ->, thick] (3.6,5.8) to[out=-90,in=90] (3.8,3.3); +\draw[red, ->, thick] (4.1,5.8) to[out=-90,in=90] (5.3,2.5); + +\node[myblue] at (0.25,1.2) {$i$}; +\draw[myblue, ->, thick](0.75, 1.2) -- (1.5, 1.2); +\node[myblue] at (5.5, 5.75) {$j$}; +\draw[myblue, ->, thick](5.5, 5.25) -- (5.5,4.5); + +\node[mypurple] at (9, 0) {next}; + +\end{tikzpicture} + diff --git a/Notes/algorithms.tex b/Notes/algorithms.tex index e353873..967735f 100644 --- a/Notes/algorithms.tex +++ b/Notes/algorithms.tex @@ -214,7 +214,7 @@ \chapter{Algorithms and running time analysis} \begin{figure} \centering - \includegraphics[height=5cm]{figures/DeterminantAlgoSlow.jpg} + \input{./TIKZ/determinant-algo-slow.tikz} \caption{An example of the recursion tree of the algorithm from Example~\ref{exe:det}. The tree corresponds to the run of the algorithm on input $\protect\smat{ 3 & 7 & 5 \\ 2&9&8 \\ 1 & 3 & 3 }.$ } \end{figure} @@ -295,7 +295,7 @@ \section{Analysis of Gaussian elimination} \begin{figure} \centering - \includegraphics[height=5cm]{figures/Echelon.jpg} + \input{./TIKZ/echelon-gaussian-elimination.tikz} \caption{Gaussian elimination: The matrix $A'$ before the $i$-th iteration of the while loop. \label{fig:9}} \end{figure}