Skip to content

Instantly share code, notes, and snippets.

@tetsuok
Created December 9, 2013 08:56
Show Gist options
  • Select an option

  • Save tetsuok/7869320 to your computer and use it in GitHub Desktop.

Select an option

Save tetsuok/7869320 to your computer and use it in GitHub Desktop.
An example of construction of a double array.
\documentclass[t]{beamer}
\usepackage{palatino}
\usepackage{amssymb,amsmath}
\usepackage{tikz}
\usepackage{color}
\usepackage{colortbl}
\def\drawtrie{
\begin{tikzpicture}[->,thick,vertex/.style={circle,fill=white,draw=black, text=black,minimum size=13pt}]
\node[vertex] (0) at (0,0) {0};
\node[vertex] (1) at (-2, -1.5) {1};
\node[vertex] (2) at (0, -1.5) {2};
\node[vertex] (3) at (2, -1.5) {3};
\node[vertex] (4) at (-3, -3) {4};
\node[vertex] (5) at (-1, -3) {5};
\node[vertex] (6) at (2, -3) {6};
\path (0) edge node [above left] {a} (1);
\path (0) edge node [left] {b} (2);
\path (0) edge node [above right] {d} (3);
\path (1) edge node [above left] {b} (4);
\path (1) edge node [above right] {c} (5);
\path (3) edge node [right] {a} (6);
\end{tikzpicture}}
\begin{document}
\begin{frame}
\begin{center}
\drawtrie
\vspace{4mm}
\begin{tabular}{c|c|c|c|c|c|c|c|c|c}
{} & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 \\ \hline
base & & & & & & & & & \\ \hline
check & & & & & & & & &
\end{tabular}
\vspace{4mm}
'a' $\rightarrow$ 1, 'b' $\rightarrow$ 2, 'c' $\rightarrow$ 3, ...
\end{center}
\end{frame}
\begin{frame}
\begin{center}
\drawtrie
\vspace{4mm}
\begin{tabular}{c|c|c|c|c|c|c|c|c|c}
{} & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 \\ \hline
base & \only<3->{0} & & & & & & & & \\ \hline
check & & \only<4->{0} & \only<5->{0} & & \only<6->{0} & & & &
\end{tabular}
\vspace{4mm}
\only<1>{{children(0) = \{1,2,3\}}}%
\only<2,3>{n = 0, m = 1
\begin{align*}
base[n] &= m - k1 \\
&= 1 - \textsf{'a'} = 1 - 1 = 0
\end{align*}%
}
\only<4>{check[1] = 0}
\only<5>{check[1-'a'+'b'] = check[1-1+2] = check[2] = 0}
\only<6>{check[1-'a'+'d'] = check[\alert{4}] = 0}
\end{center}
\end{frame}
\begin{frame}
\begin{center}
\drawtrie
\vspace{4mm}
\begin{tabular}{c|c|c|c|c|c|c|c|c|c}
{} & 0 & 1 & 2 & 3 & 4 & \only<1>{5}\only<2->{\cellcolor{red!30!white}5} & 6 & 7 & 8 \\ \hline
base & 0 & \only<3>{\alert{3}}\only<4->{3} & & & & & & & \\ \hline
check & & {0} & {0} & & {0} & \only<4>{\alert{1}}\only<5>{1} & \only<5>{\alert{1}} & &
\end{tabular}
\vspace{4mm}
\only<1>{{children(1) = \{4,5\}}}%
\only<2,3>{m = 5\\}%
\only<3>{base[1] = m - 'b' = 5 - 2 = 3}
\only<4>{check[5] = 1}
\only<5>{check[5-'b'+'c'] = check[6] = 1}
\end{center}
\end{frame}
\begin{frame}
\begin{center}
\drawtrie
\vspace{4mm}
\begin{tabular}{c|c|c|c|c|c|c|c|c|c}
{} & 0 & 1 & 2 & \only<1>{3}\only<2->{\cellcolor{red!30!white}3} & 4 & {5} & 6 & 7 & 8 \\ \hline
base & 0 & 3 & & & \only<3>{\alert{2}}\only<4>{2} & & & & \\ \hline
check & & 0 & 0 & \only<4>{\alert{4}} & 0 & 1 & 1 & &
\end{tabular}
\vspace{4mm}
\only<1>{children(3) = 6 (n = 4)}%
\only<2,3>{n = 4, m = 3\\}%
\only<3>{base[4] = m - 'b' = 3 - 1 = 2}
\only<4>{check[3] = 4}
% \only<5>{check[5-'b'+'c'] = check[6] = 1}
\end{center}
\end{frame}
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment