How to force children in a tree to go in the right direction?

Welcome to TeX.SE!!

You want this:

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[
    level 1/.style ={sibling distance=12em},
    level 2/.style ={sibling distance=6em},
    every node/.style = {shape=circle,
    draw, align=center}]
]
  \node {1}
child { node {3} 
    child { node {9}}
    child { node {7}}}
child { node {5}
    child { node {8}
        child {edge from parent[draw=none]} % Added
        child { node {10} 
            child { node {12}}
            child { node {15}
                child { node {20}}
                child {node {18}
}}}}
child {edge from parent[draw=none]} % Added
};
\end{tikzpicture}
\end{document}

Tree

It differs from @Zarko's answer because of the left alignment of 8.


first version: ups, after seeing @manooooh answer (+1) I recognize, that I misread the question and of course the resulted tree was wrong (for correct see @manooooh answer)

second version This tree can be simply drawn with forest package. Hopefull, that this time is correct designed tree:

\documentclass[border=10pt]{standalone}
\usepackage[edges]{forest}

\begin{document}
    \begin{forest}
for tree = {draw,
           shape=circle, 
           inner sep=0pt, 
           minimum size=1.6em,
           l sep=6mm, 
           s sep=9mm  
           }
[1
    [3
        [9]
        [7]
    ]
    [5
        [8
            [,phantom]
            [10
                [12]
                [15
                    [20]
                    [18]
                ]
            ]
        ]
        [,phantom]
    ] 
]
    \end{forest}
\end{document}

enter image description here

Tags:

Tikz Pgf