I would like to highlight elements of an array swapping. Right now I have this

[![enter image description here](https://i.stack.imgur.com/mSV9Z.png)](https://i.stack.imgur.com/mSV9Z.png)

but I'd like to know three things. Firstly, how to color certain indices of this array. Second, how to color certain elements of the array. Third, how to color certain indices and its corresponding element of the array.

Any help is appreciated!

```
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\newcounter{index}

\begin{document}

\begin{figure}
\centering
  \begin{tikzpicture}
    \setcounter{index}{0}
    \coordinate (s) at (0,0);
    \foreach \num in {3, 1, 4, 1, 5}{
      \node[minimum size=6mm, draw, rectangle] at (s) {\num};
      \node at ($(s)-(0,0.5)$) {\theindex};
      \stepcounter{index}
      \coordinate (s) at ($(s) + (1,0)$);
    }
  \end{tikzpicture}
  \label{fig:testArray}
\end{figure}

\end{document}

```