[Tex/LaTex] How to draw custom nodes attached to tikz-qtree

tikz-qtreetikz-trees

I want to draw a tree which is similar to the Merge sort recursion tree in this Tikz sample from TeXample.net:

However, I don't want to draw all the + and = signs, I just want two columns: one from the left and one from the right. I'm using tikz-qtree package. I wonder is there a way to add custom node to this tree structure?

enter image description here

This is my current tree:

\documentclass[10pt,letterpaper]{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{cancel}
\usepackage{tikz-qtree}

\begin{document}
     \tikzset{edge from parent/.style=
     {draw, edge from parent path={(\tikzparentnode) -- (\tikzchildnode)}}}
    \begin{tikzpicture}[sibling distance=.5cm]
    \matrix{
    \Tree
    [.n 
        [.$\dfrac{n}{2}$ [.$\dfrac{n}{4}$ ] [.$\dfrac{n}{4}$ ] [.$\dfrac{n}{4}$ ] ] 
        [.$\dfrac{n}{2}$ [.$\dfrac{n}{4}$ ] [.$\dfrac{n}{4}$ ] [.$\dfrac{n}{4}$ ] ] 
        [.$\dfrac{n}{2}$ [.$\dfrac{n}{4}$ ] [.$\dfrac{n}{4}$ ] [.$\dfrac{n}{4}$ ] ] 
    ]
    &
    \\};
    \end{tikzpicture}

\end{document}

Edit
My current solution is to use tikz-nodes, but it looks a little odd:

\tikzset{edge from parent/.style=
    {draw, edge from parent path={(\tikzparentnode) -- (\tikzchildnode)}}}
    \begin{tikzpicture}[sibling distance=0.5cm,level distance=1.5cm,node distance=1.5cm,auto,on grid,initial text=]             
    \matrix{
    \Tree
    [.n 
        [.$\dfrac{n}{2}$ [.$\dfrac{n}{4}$ ] [.$\dfrac{n}{4}$ ] [.$\dfrac{n}{4}$ ] ] 
        [.$\dfrac{n}{2}$ [.$\dfrac{n}{4}$ ] [.$\dfrac{n}{4}$ ] [.$\dfrac{n}{4}$ ] ] 
        [.$\dfrac{n}{2}$ [.$\dfrac{n}{4}$ ] [.$\dfrac{n}{4}$ ] [.$\dfrac{n}{4}$ ] ] 
    ]
    & 
    \node (0)               {$= n$};
    \node (1) [below=of 0]  {$= 3 \cdot \dfrac{n}{2}$};
    \node (2) [below=of 1]  {$= 3^2 \cdot \dfrac{n}{2^2}$};
    \\};
    \end{tikzpicture}

Best Answer

A simpler way to do this is to just use two trees and shift the second one (and change its branch properties) using TikZ's scope mechanism:

\documentclass[10pt,letterpaper]{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{cancel}
\usepackage{tikz-qtree}

\begin{document}
     \tikzset{edge from parent/.style=
     {draw, edge from parent path={(\tikzparentnode) -- (\tikzchildnode)}}}
    \begin{tikzpicture}[sibling distance=.5cm]
    \Tree
    [.n 
        [.$\dfrac{n}{2}$ [.$\dfrac{n}{4}$ ] [.$\dfrac{n}{4}$ ] [.$\dfrac{n}{4}$ ] ] 
        [.$\dfrac{n}{2}$ [.$\dfrac{n}{4}$ ] [.$\dfrac{n}{4}$ ] [.$\dfrac{n}{4}$ ] ] 
        [.$\dfrac{n}{2}$ [.$\dfrac{n}{4}$ ] [.$\dfrac{n}{4}$ ] [.$\dfrac{n}{4}$ ] ] 
    ]

\begin{scope}[xshift=2.5in]
\tikzset{edge from parent/.style={edge from parent path={(\tikzparentnode) -- (\tikzchildnode)}},every tree node/.style={text width=4em,align=left}}
\Tree [.{$=n$}
         [.{$= 3 \cdot \dfrac{n}{2}$}
        [.{$= 3^2 \cdot \dfrac{n}{2^2}$} ]]]
\end{scope}
\end{tikzpicture}

\end{document}

output of code