I took the example of a red-black tree from the TikZ examples page and adjusted it for my own needs, but I get overlapping nodes in the bottom level of the tree:
\documentclass{article}
\usepackage{tikz}
\usepackage{subfigure}
\begin{document}
\tikzset{
treenode/.style = {align=center, circle, draw=black, inner sep=0pt, text centered, font=\sffamily, thick, text width=2em},
w/.style = {treenode, black},
b/.style = {treenode, white, fill=black},
level/.style = {sibling distance=0.45\textwidth/#1}
}
\begin{figure}
\begin{center}
\begin{subfigure}{0.45\textwidth}
\begin{tikzpicture}
\node [w] {15-8}
child {node [b] {4-9}
child {node [w] {4-2}}
child {node [w] {2-1}}
child {node [w] {3-1}}
}
child {node [b] {4-6}
child {node [w] {3-1}}
child {node [w] {3-3}}
};
\end{tikzpicture}
\caption{1}
\end{subfigure}
\begin{subfigure}{0.45\textwidth}
\caption{2}
\end{subfigure}
\vskip\baselineskip
\begin{subfigure}{0.45\textwidth}
\caption{3}
\end{subfigure}
\begin{subfigure}{0.45\textwidth}
\caption{4}
\end{subfigure}
\end{center}
\end{figure}
\end{document}
resulting in
I've tried fiddling with the sibling distance parameter but can't get it to space out the nodes properly.
I've looked at some other answers but they use different packages to draw trees. Is there a good way to draw such trees in tikz without overlapping? Possibly using all the available 0.45\textwidth to space out the leaf nodes?


sibbling distanceand the automatic which replaces tikz-tree withforest. You can choose: https://tex.stackexchange.com/questions/86919/tikz-tree-without-overlaps/87004#87004 – Ignasi Jul 30 '18 at 13:22