Trazar nodos de una lista en LaTeX con Tikz

Trazar nodos de una lista en LaTeX con Tikz

¿Cuál es la mejor manera de reproducir algo así en tikzpicture?

ingrese la descripción de la imagen aquí

Respuesta1

ingrese la descripción de la imagen aquí

El siguiente código define dos comandos.

\pointer[optional for position, label, ...]{name}{node pointed to}
\element[optional for position, label, ...]{name}{data}{node pointed to}

Un vacío node pointed tocorresponde al puntero nulo.

\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows.meta,shadows}
\usepackage{xifthen}
% definitions for list
\newcommand\boxsize{6mm}
\tikzset
  {cell/.style=
    {inner sep=0pt,minimum width=\boxsize,minimum height=\boxsize,
     drop shadow,fill=white},
   ptr/.style={Circle-stealth,shorten <=-1.5pt}
  }
\newcommand\pointer[3][]%
  {\node[draw,cell,#1] (#2) {};
   \ifthenelse{\isempty{#3}}%
     {\draw (#2.south west)--(#2.north east);}%
     {\draw[ptr] (#2.center)--(#3);}
  }
\newcommand\element[4][]%
  {\node[draw,cell,#1] (#2) {#3};
   \node[draw,cell,xshift=\boxsize] (#2ptr) at (#2) {};
   \ifthenelse{\isempty{#4}}%
     {\draw (#2ptr.south west)--(#2ptr.north east);}%
     {\draw[ptr] (#2ptr.center)--(#4);}
  }
\begin{document}
\begin{tikzpicture}
  \element{e1}{10}{}
  \element[left=of e1]{e2}{20}{e1}
  \element[left=of e2]{e3}{40}{e2}
  \element[left=of e3]{e4}{30}{e3}
  \pointer[left=5mm of e4,label=left:list]{list}{e4}
  \pointer[above=5mm of e4,label=above:cur]{cur}{e4}
  \pointer[above=5mm of list,label=above:prev]{prev}{}
\end{tikzpicture}
\end{document}

información relacionada