7.用生成函数求解下列递归方程 f(n)=2f(n/2)+cn n>1 f(1)=0 n=1

递归方程:

\[\begin{cases} f(n)=2f(n/2)+c\cdot &n>1\\\\ f(1)=0 &n=1 \end{cases} \]

换元:

\[\begin{array}[lcl] s令\quad k=2^n,f(n)=f(2^k)=h(k)\\\\\\ 则\quad h(k)=2h(k-1)+2^k \quad\quad\;\\\\\\ 故递归方程变为:\begin{cases} h(k)=2h(k-1)+2^k &k>0\\\\ h(0)=0 &k=0 \end{cases} \end{array} \]

构造生产函数求解:

\[\begin{array}[lcl] sG(x) =\sum_{k=0}^{+\infty}\left[h(k)\cdot x^k\right] \qquad\qquad\qquad (1)\\\\\\ 2x\cdot G(x) =\sum_{k=0}^{+\infty}\left[2h(k)\cdot x^{k+1}\right] \qquad\;\;\,(2)\\\\\\ (1)-(2)得:\\\\\\ (1-2x)\cdot G(x)=h(0)+\sum_{k=0}^{+\infty}\left\{\left[h\left(k+1\right)-2h\left(k\right)\right]\cdot x^{k+1}\right\}\\\\\\ \qquad\qquad\qquad\;\;\,=h(0)+C\cdot \sum_{k=0}^{+\infty}(2^{k+1}\cdot x^{k+1})\\\\\\ \qquad\qquad\qquad\;\;\,=h(0)+C\cdot \left(\frac{2x}{1-2x}\right)\\\\\\ \therefore G(x)=\frac{h(0)}{1-2x}+C\cdot \left[\frac{1}{\left(1-2x\right)^2}-\frac{1}{1-2x}\right]\\\\\\ \because h(0)=f(0)=0\\\\\\ \therefore G(x)=C\cdot \sum_{k=0}^{+\infty}\left[k\cdot(2x)^k\right]\\\\\\\qquad\quad\;\,= \sum_{k=0}^{+\infty}\left[c\cdot k\cdot (2x)^k\right]\\\\\\ \therefore h(k)=C \cdot k \cdot 2^k\\\\\\ 又\because n=2^k \therefore f(n)=c\cdot nlog_2n \end{array} \]

posted @ 2020-10-08 13:02  lvjiuluan  阅读(732)  评论(0编辑  收藏  举报