0

I basically want to draw Skip Lists like this (without the blue arrows) Skiplist

I didn't find any examples that look like this on the internet

1
  • 1
    You can use a matrix or chains. If you post something that spares others from punching in the numbers you may be getting more and quicker answers.
    – user229669
    Dec 1, 2020 at 14:09

1 Answer 1

3
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{chains}
\begin{document}
\begin{tikzpicture}[box/.style={on chain,draw,minimum width=1.5em,
    text=green!60!black,join=by abc},
    c/.style={on chain,circle,draw,inner sep=1ex},
    node distance=1.5em,abc/.style={stealth-}]
 \path[abc/.style={-stealth},start chain=going right,nodes={alias=1-\X}]
  foreach \X in {0,1,5,6,8,12,17,22,33,40,44,47} {\ifnum\X=0
  node[c]{}
  \else
  node[box]{\X}
  \fi};
 \begin{scope}[start branch=b0 going above] 
  \chainin(1-0);
  \node[c,alias=2-0]{};
  \node[c,alias=3-0]{};
 \end{scope}
 \begin{scope}[start branch=b6 going above] 
  \chainin(1-6);
  \node[box,alias=2-6]{6};
 \end{scope}
 \begin{scope}[start branch=b6 going above] 
  \chainin(1-6);
  \node[box,alias=2-6]{6};
 \end{scope}
 \begin{scope}[start branch=b17 going above] 
  \chainin(1-17);
  \node[box,alias=2-17]{17};
 \end{scope}
 \begin{scope}[start branch=b40 going above] 
  \chainin(1-40);
  \node[box,alias=2-40]{40};
  \node[box,alias=3-40]{40};
 \end{scope}
 \path foreach \X in {1,2,3} {(\X-0) node[left=1em]{$h=\X$}};
 \path[every edge/.append style={-stealth}] (2-0) edge (2-6) edge (1-0)
  (3-0) edge (2-0) edge (3-40)
  (2-6) edge (2-17) (2-17) edge (2-40);
\end{tikzpicture}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .