答案1
首次尝试使用tikz
库decorations.pathreplacing
来绘制括号
代码
\documentclass[margin=5mm,dvipsnames]{standalone}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{positioning,decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}[node distance=2cm,minimum height=1cm]
\node (A) {$n$};
\node[below left=of A] (B){$\dfrac{n}{3}$};
\node[below right=of A] (C){$\dfrac{2n}{3}$};
\begin{scope}[node distance=1cm and 1mm]
\node[below left=of B] (D){$T\left(\vphantom{\left(\dfrac{4n}{9}\right)}\dfrac{n}{9}\right)$};
\node[below right=of B] (E){$T\left(\dfrac{2n}{9}\right)$};
\node[below left=of C] (F){$T\left(\dfrac{2n}{9}\right)$};
\node[below right=of C] (I){$T\left(\dfrac{4n}{9}\right)$};
\end{scope}
\foreach \from/\to in {A/B,A/C,B/D,B/E,C/F,C/I}
{\draw(\from)--(\to);}
\draw[decorate,decoration={brace,amplitude=3mm},OliveGreen](A.45)--node[right,anchor=south west] {$\log_{3/2}n$}(I.60);
\draw[decorate,decoration={brace,mirror,amplitude=3mm},blue](A.135)--node[right,anchor=south east] {$\log_{3}n$}(D.120);
\end{tikzpicture}
\end{document}
更新
如果你想要更复杂的树,你可以利用森林。
\documentclass[margin=5mm,dvipsnames]{standalone}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{positioning,decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}[node distance=2cm and 2cm,minimum height=1cm]
\node (A) {$n$};
\node[below left=of A] (B){$\dfrac{n}{3}$};
\node[below right=of A] (C){$\dfrac{2n}{3}$};
\node[right =1cm of B](G){$\dfrac{n}{3}$}(C);
\node[left =1cm of C](K){$\dfrac{n}{3}$}(C);
\begin{scope}[node distance=1cm and 1mm]
\node[below left=of B] (D){$T\left(\vphantom{\left(\dfrac{4n}{9}\right)}\dfrac{n}{9}\right)$};
\node[below right=of B] (E){$T\left(\dfrac{2n}{9}\right)$};
\node[below left=of C] (F){$T\left(\dfrac{2n}{9}\right)$};
\node[below right=of C] (I){$T\left(\dfrac{4n}{9}\right)$};
\end{scope}
\foreach \from/\to in {A/B,A/C,A/G,A/K,B/D,B/E,C/F,C/I}
{\draw(\from)--(\to);}
\draw[decorate,decoration={brace,amplitude=3mm},OliveGreen](A.45)--node[right,anchor=south west] {$\log_{3/2}n$}(I.60);
\draw[decorate,decoration={brace,mirror,amplitude=3mm},blue](A.135)--node[right,anchor=south east] {$\log_{3}n$}(D.120);
\end{tikzpicture}
\end{document}