Hi Leute,
die erste Variante war perfekt. Doch wenn ich das Dreieck umdrehen möchte, funktionieren die Abstände nicht mehr richtig. Es sieht bei mir jetzt wie folgt aus.
\begin{figure}[H]
\centering
\begin{tikzpicture}
\matrix(M)[matrix of nodes,row sep=-\pgflinewidth,column sep=-\pgflinewidth,
nodes={draw,minimum width=4em,minimum height=4em}]
{
$ A,B $ & $ A,B $ & $ B $ & $ B $ & $ B $ \\
$ A,S $ & $ S $ & - & - \\
$ A,S,C $ & $ C $ & - \\
$ S,C $ & - \\
$ C $ \\
};
\foreach[count=\j] \i in {$ a $,$ a $,$ b $, $ b $, $ b $}\node[above=0pt of M-1-\j]{\i};
\end{tikzpicture}
\caption{CYK-Algorithmus}
\end{figure}