Skip to content

Commit

Permalink
escape all whitespace characters in md image links to make them prope…
Browse files Browse the repository at this point in the history
…rly parsed
  • Loading branch information
m2jean committed Aug 2, 2017
1 parent ef9eda3 commit 0f83057
Show file tree
Hide file tree
Showing 28 changed files with 192 additions and 411 deletions.
65 changes: 18 additions & 47 deletions C04-Recurrences/4.1.md
Original file line number Diff line number Diff line change
@@ -1,97 +1,68 @@
### Exercises 4.1-1
***
Show that the solution of ![](http://latex.codecogs.com/gif.latex? T\(n\) = T\(\\lceil n/2 \\rceil\) + 1) is O(lg n).
Show that the solution of ![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20=%20T\(\\lceil%20n/2%20\\rceil\)%20+%201) is O(lg n).

### `Answer`
我们猜想 ![](http://latex.codecogs.com/gif.latex? T\(n\) \\le c\\lg\(n-2\) )
我们猜想 ![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20\\le%20c\\lg\(n-2\)%20)

![](http://latex.codecogs.com/gif.latex? T\(n\) = T\(\\lceil n/2 \\rceil\) + 1 \\le T\(n/2+1\) +1 \\\\ ~
\\hspace{15 mm} \\le c\\lg\(n/2-1\)+1 \\\\ ~
\\hspace{15 mm} =clg\(n-2\) -c\\lg2 + 1 \\\\ ~
\\hspace{15 mm} \\le clg\(n-2\)
)
![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20=%20T\(\\lceil%20n/2%20\\rceil\)%20+%201%20\\le%20T\(n/2+1\)%20+1%20\\\\%20%20~%0d%0a\\hspace{15%20mm}%20\\le%20c\\lg\(n/2-1\)+1%20%20\\\\%20%20~%0d%0a\\hspace{15%20mm}%20=clg\(n-2\)%20-c\\lg2%20+%201%20\\\\%20%20~%0d%0a\\hspace{15%20mm}%20\\le%20clg\(n-2\)%0d%0a)


### Exercises 4.1-2
***
We saw that the solution of ![](http://latex.codecogs.com/gif.latex? T\(n\) = 2T\(\\lfloor n/2 \\rfloor\) + n)
We saw that the solution of ![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20=%202T\(\\lfloor%20n/2%20\\rfloor\)%20+%20n)
is O(n lg n). Show that the solution of this recurrence is also Ω(n lg n). Conclude that the solution is Θ(n lg n).

### `Answer`
我们假设![](http://latex.codecogs.com/gif.latex? T\(n\) \\ge cn\\lg{n} )
我们假设![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20\\ge%20cn\\lg{n}%20)

![](http://latex.codecogs.com/gif.latex? T\(n\) = 2T\(\\lfloor n/2 \\rfloor\) + n \\\\ ~
\\hspace{15 mm} \\ge cn\(\\lg{n} - \\lg{2}\)+n \\\\ ~
\\hspace{15 mm} =cn\\lg{n} +\(1-c\\lg{2}\)n \\\\ ~
\\hspace{15 mm} \\ge cnlg\(n\)
\\\\ ~
\\hspace{15 mm} for ~ 1-c\\lg{2} < 0
)
![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20=%202T\(\\lfloor%20n/2%20\\rfloor\)%20+%20n%20\\\\%20%20~%0d%0a\\hspace{15%20mm}%20\\ge%20cn\(\\lg{n}%20-%20\\lg{2}\)+n%20\\\\%20%20~%0d%0a\\hspace{15%20mm}%20=cn\\lg{n}%20+\(1-c\\lg{2}\)n%20\\\\%20%20~%0d%0a\\hspace{15%20mm}%20\\ge%20cnlg\(n\)%0d%0a\\\\%20%20~%0d%0a\\hspace{15%20mm}%20for%20~%201-c\\lg{2}%20<%200%0d%0a)


### Exercises 4.1-3
***
Show that by making a different inductive hypothesis, we can overcome the difficulty with the boundary condition T (1) = 1 for the recurrence (4.4) without adjusting the boundary conditions for the inductive proof.

### `Answer`
我们假设 ![](http://latex.codecogs.com/gif.latex? T\(n\) \\le n\\lg{n}+n)
我们假设 ![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20\\le%20n\\lg{n}+n)

![](http://latex.codecogs.com/gif.latex? T\(n\) \\le 2\(c\\lfloor n/2 \\rfloor \\lg\(\\lfloor n/2 \\rfloor\) + \\lfloor n/2 \\rfloor\) + n \\\\ ~
\\hspace{15 mm} \\le 2c\(n/2\)\\lg\(n/2\) + 2\(n/2\) + n \\\\ ~
\\hspace{15 mm} \\le cn\\lg\(n/2\) + 2n \\\\ ~
\\hspace{15 mm} \\le cn\\lg{n} - \\lg{2}cn + 2n \\\\ ~
\\hspace{15 mm} \\le cn\\lg{n} + \(2-c\)n \\\\ ~
\\hspace{15 mm} \\le cn\\lg{n} + n ~~~~~~~~~~~~ for ~ c \\ge 1
)
![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20\\le%202\(c\\lfloor%20n/2%20\\rfloor%20\\lg\(\\lfloor%20n/2%20\\rfloor\)%20+%20\\lfloor%20n/2%20\\rfloor\)%20+%20n%20\\\\%20%20~%0d%0a\\hspace{15%20mm}%20\\le%202c\(n/2\)\\lg\(n/2\)%20+%202\(n/2\)%20+%20n%20\\\\%20%20~%0d%0a\\hspace{15%20mm}%20\\le%20cn\\lg\(n/2\)%20+%202n%20\\\\%20%20~%0d%0a\\hspace{15%20mm}%20\\le%20cn\\lg{n}%20-%20\\lg{2}cn%20+%202n%20\\\\%20%20~%0d%0a\\hspace{15%20mm}%20\\le%20cn\\lg{n}%20+%20\(2-c\)n%20\\\\%20%20~%0d%0a\\hspace{15%20mm}%20\\le%20cn\\lg{n}%20+%20n%20~~~~~~~~~~~~%20for%20~%20c%20\\ge%201%0d%0a)

### Exercises 4.1-4
***
Show that Θ(n lg n) is the solution to the "exact" recurrence (4.2) for merge sort.

### `Answer`
我们假设![](http://latex.codecogs.com/gif.latex? T\(n\) \\ge cn\\lg{n} )
我们假设![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20\\ge%20cn\\lg{n}%20)

![](http://latex.codecogs.com/gif.latex? T\(n\) \\ge 2T\(n/2\) + kn \\\\ ~
\\hspace{15 mm} =cn\\lg{n} +\(k-c\\lg{2}\)n \\\\ ~
\\hspace{15 mm} \\ge cn\\lg{n} ~~~~~~ if ~ k \\le c\\lg{2}
)
![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20\\ge%202T\(n/2\)%20+%20kn%20\\\\%20%20~%0d%0a\\hspace{15%20mm}%20=cn\\lg{n}%20+\(k-c\\lg{2}\)n%20\\\\%20%20~%0d%0a\\hspace{15%20mm}%20\\ge%20cn\\lg{n}%20%20~~~~~~%20if%20~%20k%20\\le%20c\\lg{2}%0d%0a)

我们假设![](http://latex.codecogs.com/gif.latex? T\(n\) \\le c\(n-2\)\\lg\(n-2\) )
我们假设![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20\\le%20c\(n-2\)\\lg\(n-2\)%20)

![](http://latex.codecogs.com/gif.latex? T\(n\) \\le T\(n/2+1\) + T\(n/2\) + kn \\\\ ~
\\hspace{15 mm} \\le c\(n-2\)\\lg\(\\frac{n-2}{2}\) + kn \\\\ ~
\\hspace{15 mm} = c\(n-2\)\\lg\(n-2\) +kn - c\\lg{2}\(n-2\) \\\\ ~
\\hspace{15 mm} \\le c\(n-2\)\\lg\(n-2\) ~~~~~~~~if~~kn \\le c\\lg{2}\(n-2\)
)
![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20\\le%20T\(n/2+1\)%20+%20T\(n/2\)%20+%20kn%20\\\\%20%20~%0d%0a\\hspace{15%20mm}%20\\le%20c\(n-2\)\\lg\(\\frac{n-2}{2}\)%20+%20kn%20\\\\%20%20~%0d%0a\\hspace{15%20mm}%20=%20c\(n-2\)\\lg\(n-2\)%20+kn%20-%20c\\lg{2}\(n-2\)%20\\\\%20%20~%0d%0a\\hspace{15%20mm}%20\\le%20c\(n-2\)\\lg\(n-2\)%20~~~~~~~~if~~kn%20\\le%20c\\lg{2}\(n-2\)%0d%0a)

### Exercises 4.1-5
***
Show that the solution to ![](http://latex.codecogs.com/gif.latex? T\(n\) = 2T\(\\lfloor n/2 \\rfloor + 17\) + n ) is O(n lg n).
Show that the solution to ![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20=%202T\(\\lfloor%20n/2%20\\rfloor%20+%2017\)%20+%20n%20) is O(n lg n).

### `Answer`
我们假设![](http://latex.codecogs.com/gif.latex? T\(n\) \\le c\(n-a\)\\lg\(n-a\) )
我们假设![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20\\le%20c\(n-a\)\\lg\(n-a\)%20)

![](http://latex.codecogs.com/gif.latex? T\(n\) \\le 2c\(\\lfloor n/2 \\rfloor + 17 - a\)\\lg\(\\lfloor n/2 \\rfloor + 17-a\) + n\\\\ ~
\\hspace{15 mm} \\le 2c\(n/2 +1+ 17 - a\)\\lg\( n/2 +1+ 17-a\) + n \\\\ ~
\\hspace{15 mm} \\le c\(n+36-2a\)\\lg\(\\frac{n+36-2a}{2}\)+n \\\\ ~
\\hspace{15 mm} \\le c\(n+36-2a\)\\lg\(n+36-2a\) - c\(n+36-2a\)+n \\\\ ~
\\hspace{15 mm} \\le c\(n+36-2a\)\\lg\(n+36-2a\) ~~~if ~~ c > 1 \\\\ ~
\\hspace{15 mm} \\le c\(n-a\)\\lg\(n-a\) ~~~~if ~~ a \ge 36
)
![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20\\le%202c\(\\lfloor%20n/2%20\\rfloor%20+%2017%20-%20a\)\\lg\(\\lfloor%20n/2%20\\rfloor%20+%2017-a\)%20+%20n\\\\%20%20~%0d%0a\\hspace{15%20mm}%20\\le%20%202c\(n/2%20+1+%2017%20-%20a\)\\lg\(%20n/2%20+1+%2017-a\)%20+%20n%20\\\\%20%20~%0d%0a\\hspace{15%20mm}%20\\le%20c\(n+36-2a\)\\lg\(\\frac{n+36-2a}{2}\)+n%20\\\\%20%20~%0d%0a\\hspace{15%20mm}%20\\le%20c\(n+36-2a\)\\lg\(n+36-2a\)%20-%20c\(n+36-2a\)+n%20\\\\%20%20~%0d%0a\\hspace{15%20mm}%20\\le%20c\(n+36-2a\)\\lg\(n+36-2a\)%20~~~if%20~~%20c%20>%201%20\\\\%20%20~%20%0d%0a\\hspace{15%20mm}%20\\le%20c\(n-a\)\\lg\(n-a\)%20~~~~if%20~~%20a%20\ge%2036%0d%0a)

### Exercises 4.1-6
***
Solve the recurrence ![](http://latex.codecogs.com/gif.latex? T\(n\) = 2T\(\\sqrt{n}\)+1 )
Solve the recurrence ![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20=%202T\(\\sqrt{n}\)+1%20)
by making a change of variables. Your solution should be asymptotically tight. Do not worry about whether values are integral.

### `Answer`
设n = lgn,得到新的递归式

![](http://latex.codecogs.com/gif.latex? T\(2^n\) = 2T\(2^{n/2}\) + 1)
![](http://latex.codecogs.com/gif.latex?%20T\(2^n\)%20=%202T\(2^{n/2}\)%20+%201)

再令S(n) = T(2^n)可以得到

![](http://latex.codecogs.com/gif.latex? S\(n\) = S2\(m/2\) + 1)
![](http://latex.codecogs.com/gif.latex?%20S\(n\)%20=%20S2\(m/2\)%20+%201)

按照前面的方法解这个递归式即可

Expand Down
44 changes: 15 additions & 29 deletions C04-Recurrences/4.2.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@
### Exercises 4.2-1
***
Use a recursion tree to determine a good asymptotic upper bound on the recurrence
![](http://latex.codecogs.com/gif.latex? T\(n\) = 3T\(\\lceil n/2 \\rceil\) + n). Use the substitution method to verify your answer.
![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20=%203T\(\\lceil%20n/2%20\\rceil\)%20+%20n). Use the substitution method to verify your answer.

### `Answer`
![recursion tree](./repo/s2/1.png)

树的高度是lgn,有3^lgn个叶子节点.

![](http://latex.codecogs.com/gif.latex? T\(n\) = n\\sum_{i = 0}^{lg\(n\)-1}\(\\frac{3}{2}\)^i + \\Theta\(3^{\\lg{n}}\) \\\\ ~
\\hspace{15 mm} = \\Theta\(n^{\\lg{3}}\) + \\Theta\(3^{\\lg{n}}\) \\\\ ~
\\hspace{15 mm} = \\Theta\(n^{\\lg{3}}\) + \\Theta\(n^{\\lg{3}}\) \\\\ ~
\\hspace{15 mm} = \\Theta\(n^{\\lg{3}}\)
)
![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20=%20n\\sum_{i%20=%200}^{lg\(n\)-1}\(\\frac{3}{2}\)^i%20+%20\\Theta\(3^{\\lg{n}}\)%20\\\\%20%20~%0d%0a\\hspace{15%20mm}%20=%20\\Theta\(n^{\\lg{3}}\)%20+%20\\Theta\(3^{\\lg{n}}\)%20\\\\%20%20~%0d%0a\\hspace{15%20mm}%20=%20\\Theta\(n^{\\lg{3}}\)%20+%20\\Theta\(n^{\\lg{3}}\)%20\\\\%20%20~%0d%0a\\hspace{15%20mm}%20=%20\\Theta\(n^{\\lg{3}}\)%0d%0a)

我们猜想 ![](http://latex.codecogs.com/gif.latex? T\(n\) \\le cn^{\\lg{3}}+2n )
我们猜想 ![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20\\le%20cn^{\\lg{3}}+2n%20)

![](http://latex.codecogs.com/gif.latex? T\(n\) \\le 3c\(n/2\)^{\\lg{3}} + 2n \\\\ ~
\\hspace{15 mm} \\le cn^{\\lg{3}}+2n \\\\ ~
\\hspace{15 mm} = \\Theta\(n^{\\lg{3}}\)
)
![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20\\le%203c\(n/2\)^{\\lg{3}}%20+%202n%20%20\\\\%20%20~%0d%0a\\hspace{15%20mm}%20\\le%20cn^{\\lg{3}}+2n%20%20\\\\%20%20~%0d%0a\\hspace{15%20mm}%20=%20\\Theta\(n^{\\lg{3}}\)%0d%0a)


### Exercises 4.2-2
***
Argue that the solution to the recurrence
![](http://latex.codecogs.com/gif.latex? T\(n\) = T\(n/3\) + T\(2n/3\) + cn )
![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20=%20T\(n/3\)%20+%20T\(2n/3\)%20+%20cn%20)
, where c is a constant, is Ω(nlgn) by appealing to the recurrsion tree.

### `Answer`
Expand All @@ -35,20 +28,20 @@ Argue that the solution to the recurrence
### Exercises 4.2-3
***
Draw the recursion tree for
![](http://latex.codecogs.com/gif.latex? T\(n\) = 4T\(\\lfloor n/2 \\rfloor\) + cn)
![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20=%204T\(\\lfloor%20n/2%20\\rfloor\)%20+%20cn)
,where c is a constant, and provide a tight asymptotic bound on its solution. Verify your bound by the substitution method.
### `Answer`
![recursion tree](./repo/s2/2.png)

很明显是n^2的级别

我们假设 ![](http://latex.codecogs.com/gif.latex? T\(n\) \\le n^2+2cn)
我们假设 ![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20\\le%20n^2+2cn)

![](http://latex.codecogs.com/gif.latex? T\(n\) \\le 4c\(n/2\)^2 + 2cn/2+cn \\le cn^2+2cn)
![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20\\le%20%204c\(n/2\)^2%20+%202cn/2+cn%20\\le%20cn^2+2cn)

我们假设 ![](http://latex.codecogs.com/gif.latex? T\(n\) \\ge n^2+2cn)
我们假设 ![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20\\ge%20n^2+2cn)

![](http://latex.codecogs.com/gif.latex? T\(n\) \\ge 4c\(n/2\)^2 + 2cn/2+cn \\ge cn^2+2cn)
![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20\\ge%20%204c\(n/2\)^2%20+%202cn/2+cn%20\\ge%20cn^2+2cn)

### Exercises 4.2-4
***
Expand All @@ -57,18 +50,11 @@ Use a recursion tree to give an asymptotically tight solution to the recurrence
### `Answer`
![recursion tree](./repo/s2/3.png)
file:///Users/ganzhenchao/Workspaces/CLRS/C04-Recurrences/repo/s2/4.png
![](http://latex.codecogs.com/gif.latex? T\(n\) = \\sum_{i=0}^{n/a}c\(n-ia\) + \(n/a\)ca
= \\Theta\(n^2\))
![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20=%20\\sum_{i=0}^{n/a}c\(n-ia\)%20+%20\(n/a\)ca%0d%0a=%20\\Theta\(n^2\))

我们假设 ![](http://latex.codecogs.com/gif.latex? T\(n\) \\le cn^2)
我们假设 ![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20\\le%20cn^2)

![](http://latex.codecogs.com/gif.latex? T\(n\) \\le c\(n-a\)^2 + ca + cn \\\\ ~
\\hspace{15 mm} \\le cn^2-2acn+ca+cn \\\\ ~
\\hspace{15 mm} \\le cn^2-c\(2an-a-n\) \\\\ ~
\\hspace{15 mm}\\le cn^2 - cn ~~~~ if ~~ a > 1/2,n > 2a \\\\ ~
\\hspace{15 mm}\\le cn^2 \\\\ ~
\\hspace{15 mm} = \\Theta\(n^2\)
)
![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20\\le%20c\(n-a\)^2%20+%20ca%20+%20cn%20%20\\\\%20%20~%0d%0a\\hspace{15%20mm}%20\\le%20cn^2-2acn+ca+cn%20%20\\\\%20%20~%0d%0a\\hspace{15%20mm}%20\\le%20cn^2-c\(2an-a-n\)%20\\\\%20%20~%0d%0a\\hspace{15%20mm}\\le%20cn^2%20-%20cn%20~~~~%20if%20~~%20a%20>%201/2,n%20>%202a%20\\\\%20%20~%0d%0a\\hspace{15%20mm}\\le%20cn^2%20\\\\%20%20~%0d%0a\\hspace{15%20mm}%20=%20\\Theta\(n^2\)%0d%0a)

另外一个方向的证明和这个基本一样.

Expand All @@ -80,9 +66,9 @@ T((1 - α)n) + cn, where α is a constant in the range 0 <α < 1 and c > 0 is al
### `Answer`
![recursion tree](./repo/s2/4.png)

可以假设α < 1/2,因此树的高度有![](http://latex.codecogs.com/gif.latex? \\log_{1/ \\alpha}{n} )
可以假设α < 1/2,因此树的高度有![](http://latex.codecogs.com/gif.latex?%20\\log_{1/%20\\alpha}{n}%20)

![](http://latex.codecogs.com/gif.latex? T\(n\) = \\sum_{i = 0}^{\\log_{1/ \\alpha}{n}}cn + \\Theta\(n\) = cn\\log_{1/ \\alpha}{n} + \\Theta\(n\) = \\Theta\(n\\lg{n}\) )
![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20=%20\\sum_{i%20=%200}^{\\log_{1/%20\\alpha}{n}}cn%20+%20\\Theta\(n\)%20=%20cn\\log_{1/%20\\alpha}{n}%20+%20\\Theta\(n\)%20=%20\\Theta\(n\\lg{n}\)%20)

***
Follow [@louis1992](https://github.com/gzc) on github to help finish this task.
Expand Down
34 changes: 16 additions & 18 deletions C04-Recurrences/4.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,32 @@
***
Use the master method to give tight asymptotic bounds for the following recurrences.

a. ![](http://latex.codecogs.com/gif.latex? T\(n\) = 4T\(n/2\)+n )
a. ![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20=%204T\(n/2\)+n%20)

b. ![](http://latex.codecogs.com/gif.latex? T\(n\) = 4T\(n/2\)+n^2 )
b. ![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20=%204T\(n/2\)+n^2%20)

c. ![](http://latex.codecogs.com/gif.latex? T\(n\) = 4T\(n/2\)+n^3 )
c. ![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20=%204T\(n/2\)+n^3%20)

### `Answer`
![](http://latex.codecogs.com/gif.latex? n^{\\log_{b}{a}} = n^{\\log_{2}{4}} = n^2)
![](http://latex.codecogs.com/gif.latex?%20n^{\\log_{b}{a}}%20=%20n^{\\log_{2}{4}}%20=%20n^2)

a. ![](http://latex.codecogs.com/gif.latex? \\Theta\(n^2\) )
a. ![](http://latex.codecogs.com/gif.latex?%20\\Theta\(n^2\)%20)

b. ![](http://latex.codecogs.com/gif.latex? \\Theta\(n^2 \\lg{n}\) )
b. ![](http://latex.codecogs.com/gif.latex?%20\\Theta\(n^2%20\\lg{n}\)%20)

c. ![](http://latex.codecogs.com/gif.latex? \\Theta\(n^3\) )
c. ![](http://latex.codecogs.com/gif.latex?%20\\Theta\(n^3\)%20)


### Exercises 4.3-2
***
The recurrence T(n) = 7T (n/2)+n2 describes the running time of an algorithm A. A competing algorithm A′ has a running time of T′(n) = aT′(n/4) + n2. What is the largest integer value for a such that A′ is asymptotically faster than A?

### `Answer`
根据主定理,算法A的运行时间为![](http://latex.codecogs.com/gif.latex? T\(n\) = \\Theta\(\\lg{7}\)\ \\approx n^{2.8} )
根据主定理,算法A的运行时间为![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20=%20\\Theta\(\\lg{7}\)\ \\approx%20n^{2.8}%20)

A'的运行时间在a > 16时超过n^2,此时

![](http://latex.codecogs.com/gif.latex? T\(n\) = \\Theta\(n^{\\log_{4}{a}}\) < \\lg{7} = \\log_{4}{49})
![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20=%20\\Theta\(n^{\\log_{4}{a}}\)%20<%20%20\\lg{7}%20=%20\\log_{4}{49})

所以最大值为48

Expand All @@ -38,25 +38,25 @@ A'的运行时间在a > 16时超过n^2,此时
Use the master method to show that the solution to the binary-search recurrence T(n) = T (n/2)
+ Θ(1) is T(n) = Θ(lg n). (See Exercise 2.3-5 for a description of binary search.)
### `Answer`
![](http://latex.codecogs.com/gif.latex? n^{\\log_{b}{a}} = n^{\\log_{2}{1} = 1} )
![](http://latex.codecogs.com/gif.latex?%20n^{\\log_{b}{a}}%20=%20n^{\\log_{2}{1}%20=%201}%20)

so the solution is Θ(lgn).


### Exercises 4.3-4
***
Can the master method be applied to the recurrence
![](http://latex.codecogs.com/gif.latex? T\(n\) = 4T\(n/2\) + n^2 \\lg{n} )
![](http://latex.codecogs.com/gif.latex?%20T\(n\)%20=%204T\(n/2\)%20+%20n^2%20\\lg{n}%20)
Why or why not? Give an asymptotic upper bound for this recurrence.

### `Answer`
![](http://latex.codecogs.com/gif.latex? n^{\\log_{b}{a}} = n^{\\log_{2}{4}} = n^2 )
![](http://latex.codecogs.com/gif.latex?%20n^{\\log_{b}{a}}%20=%20n^{\\log_{2}{4}}%20=%20n^2%20)

The problem is that it is not polynomially larger. The ratio 
![](http://latex.codecogs.com/gif.latex? f\(n\) / n^{\\log_{b}{a}} = \\lg{n})
![](http://latex.codecogs.com/gif.latex?%20f\(n\)%20/%20n^{\\log_{b}{a}}%20=%20\\lg{n})
is asymptotically less than
![](http://latex.codecogs.com/gif.latex? n^\\epsilon ) for any positive constant
![](http://latex.codecogs.com/gif.latex? \\epsilon )
![](http://latex.codecogs.com/gif.latex?%20n^\\epsilon%20) for any positive constant
![](http://latex.codecogs.com/gif.latex?%20\\epsilon%20)

### Exercises 4.3-5
***
Expand All @@ -71,9 +71,7 @@ let

我们需要证明

![](http://latex.codecogs.com/gif.latex? \\frac{n}{2}\( 2 - \\cos\(\\frac{n}{2}\)}\) < cn \\\\ ~ \\Rightarrow c > \\frac{2- \\cos\(n/2\)}{2} \\\\ ~
\\Rightarrow c > \\frac{3}{2}
)
![](http://latex.codecogs.com/gif.latex?%20\\frac{n}{2}\(%202%20-%20\\cos\(\\frac{n}{2}\)}\)%20<%20cn%20\\\\%20%20~%20\\Rightarrow%20c%20>%20\\frac{2-%20\\cos\(n/2\)}{2}%20\\\\%20%20~%20%0d%0a\\Rightarrow%20c%20>%20\\frac{3}{2}%0d%0a)

***
Follow [@louis1992](https://github.com/gzc) on github to help finish this task.
Expand Down
Loading

0 comments on commit 0f83057

Please sign in to comment.