Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to draw a picture like this:The picture

Can we done it with tikz?

share|improve this question
    
In its current form, your question might not receive many answers. Please take a look at the How to Ask-page and try to improve your question according to the guidance found there. This may require you to show some effort on your part in terms of attempting a solution. –  percusse Oct 14 '12 at 8:10
    
add comment

1 Answer

You can use this as a starting point:

\documentclass{article}
\usepackage{amsmath}
\usepackage{rotating}
\usepackage{tikz}
\usetikzlibrary{positioning,trees,calc,decorations.pathreplacing}

\newcommand\dotstheta{\overset{\vdots}{\Theta(1)}}
\begin{document}

\begin{sidewaysfigure}
\centering
\begin{tikzpicture}[
level 1/.style={sibling distance=45mm},
level 2/.style={sibling distance=15mm},
level 3/.style={sibling distance=4mm,level distance=8mm},
]

% the tree
\node (r1) {$f(n)$}
child { node (l2) {$f(n/b)$} 
  { child {node (l3) {$f(n/b^2)$} child child child} 
    child {node {$f(n/b^2)$} child child child} 
    child {node (ll3) {$f(n/b^2)$} child child child} 
  }
}
child { node (c2) {$f(n/b)$} 
  { child {node  {$f(n/b^2)$} child child child} 
    child {node (cc2) {$f(n/b^2)$} child child child} 
    child {node  {$f(n/b^2)$} child child child} 
  }
}
child { node (r2) {$f(n/b)$} 
  { child {node (rr3) {$f(n/b^2)$} child child child} 
    child {node {$f(n/b^2)$} child child child} 
    child {node (r3) {$f(n/b^2)$} child child child} 
  } 
};
% the last line of thetas
\node[anchor=north,inner sep=0pt] (theta) at ([yshift=-1cm]cc2) {$\dotstheta\dotstheta\dotstheta\dotstheta\dotstheta\dotstheta\dotstheta\dotstheta%
\dotstheta\dotstheta\dotstheta\dotstheta\dotstheta\dotstheta\dotstheta\dotstheta%
\dotstheta\dotstheta$};

% two auxiliary coordinates
\coordinate (aux1) at ( $ (r1) + (8.5,0) $ );
\coordinate (aux2) at ( $ (r1) + (-7,0) $ );

% the nodes to the right of the tree
\node(t1) at (aux1) {$f(n)$};
\node(t2) at (r2-|aux1) {$af(n/b)$};
\node(t3) at (r3-|aux1) {$a^2f(n/b^2)$};
\node(t4) at (theta.184-|aux1) {$\Theta\bigl(n^{\log_{b}n}\bigr)$};

% arrows from the tree to the nodes on the right
\foreach \i in {1,2,3}
  \draw[->,line width=1pt,dashed] (r\i) -- (t\i);
\draw[->,line width=1pt,dashed,shorten <=2pt] (theta.-4) -- (t4);

% the arrow to the left of the tree
\draw[<->] (aux2) -- node[fill=white] {$\log_{b}n$} (aux2|-theta.184);

% the brace at the bottom
\draw[decorate,decoration={brace,raise=2pt}] (theta.south east) -- node[label={[label distance=4pt]below:$n^{\log_{b}n}$}]{}  (theta.south west);

% the rule with the total
\draw ([yshift=-1cm]t4.east) -- +(-4cm,0);
\node[below = 2cm of t4.east,anchor=east] {Total: $\Theta\bigl(n^{\log_{b}n}\bigr) + \displaystyle\sum_{j=0}^{\log_{b}n-1}a^{j}f(n/b^{j})$};
\end{tikzpicture}
\end{sidewaysfigure}

\end{document}

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.