I want to visualize a sorting algorithm by highlighting the changes made in each step. E. g.:
[ a_1 a_2 a_3 a_4 ]
X
[ a_1 a_2 a_4 a_3 ]
X
[ a_1 a_4 a_2 a_3 ]
and so on.
Instead of the “X” I‘d like two arrows pointing from the center-bottom to the center-top of the elements would be better (but that‘s hard to do in ASCII at this solution, so I could not show that above …).
Additionally only neighbouring elements are exchanged, so I don‘t care for more complicating cases (e. g. exchanging a_1 with a_4 in the example above) for now. (But I do welcome answers which care for this point as well!)
How to do that with LaTeX? Show me beautiful arrow answers. :)
Thanks in advance.
PS: Although I added an tikz-arrows tag I do welcome solutions which do not use tikz. But I thought most answers will use tikz anyway, so the tag should be unproblematic.


in/outoptions. When drawing the lines, instead of--I use nowto. – JLDiaz May 14 '14 at 07:18beamerframe and struggle with some errors, see a solution at https://tex.stackexchange.com/questions/208408/tikz-matrix-undefined-control-sequence – Arne Sep 09 '22 at 07:41