Is it possible to draw draw direct address tables
? Original examples could be seen from Cormen's Introduction to Algorithms, Second Edition
book page 223 Figure 11.1:
What's in my mind is following figure with additional step for pointers:
My current code:
\documentclass[tikz,border=2mm]{standalone}
\begin{document}
\begin{tikzpicture}[font=\large,thick,>=stealth]
\foreach \j in {0,1,4,6,7}{
\draw (1,-\j)--+(-1,-1);
}
\draw (0,0) grid (1,-8);
\foreach \i in {0,...,6}{
\path (-0.5,-\i-0.5) node{$ \i $};
}
\foreach \i/\j in {2/5, 3/9, 5/5, 6/5}{
\draw[->] (0.5,-\i-0.5)--+(1.5,0)
node[shift={(0.5,0)}]{$ \j $};
\draw (2,-\i) grid +(2,-1);
}
\foreach \i/\j in {2.5/5, 5.5/8}{
\draw[->] (3.5,-\i)--+(1.5,0) node[shift={(0.5,0)}]{$ \j $};
}
\draw (5,-2) grid +(3,-1) (5,-5) grid +(3,-1);
\end{tikzpicture}
\end{document}
Thank you for your valuable time and help.
Best Answer
It's maybe not optimal in term of for loops, but I think it does what you asked