-
Notifications
You must be signed in to change notification settings - Fork 0
/
simple_proof_weak_master_theorem.html
360 lines (282 loc) · 9.36 KB
/
simple_proof_weak_master_theorem.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
<!DOCTYPE html>
<html lang="en">
<head>
<!-- 2022-07-23 Sat 05:11 -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Simple proof weak master theorem</title>
<meta name="generator" content="Org mode">
<meta name="author" content="ivanaf">
<link rel="stylesheet" type="text/css" href="css/org.css"/>
<link rel="icon" href="ico/favicon.ico" type="image/x- icon">
<script type="text/javascript">
/*
@licstart The following is the entire license notice for the
JavaScript code in this tag.
Copyright (C) 2012-2020 Free Software Foundation, Inc.
The JavaScript code in this tag is free software: you can
redistribute it and/or modify it under the terms of the GNU
General Public License (GNU GPL) as published by the Free Software
Foundation, either version 3 of the License, or (at your option)
any later version. The code is distributed WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
As additional permission under GNU GPL version 3 section 7, you
may distribute non-source (e.g., minimized or compacted) forms of
that code without the copy of the GNU GPL normally required by
section 4, provided you include this license notice and a URL
through which recipients can access the Corresponding Source.
@licend The above is the entire license notice
for the JavaScript code in this tag.
*/
<!--/*--><![CDATA[/*><!--*/
function CodeHighlightOn(elem, id)
{
var target = document.getElementById(id);
if(null != target) {
elem.cacheClassElem = elem.className;
elem.cacheClassTarget = target.className;
target.className = "code-highlighted";
elem.className = "code-highlighted";
}
}
function CodeHighlightOff(elem, id)
{
var target = document.getElementById(id);
if(elem.cacheClassElem)
elem.className = elem.cacheClassElem;
if(elem.cacheClassTarget)
target.className = elem.cacheClassTarget;
}
/*]]>*///-->
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
displayAlign: "center",
displayIndent: "0em",
"HTML-CSS": { scale: 100,
linebreaks: { automatic: "false" },
webFont: "TeX"
},
SVG: {scale: 100,
linebreaks: { automatic: "false" },
font: "TeX"},
NativeMML: {scale: 100},
TeX: { equationNumbers: {autoNumber: "AMS"},
MultLineWidth: "85%",
TagSide: "right",
TagIndent: ".8em"
}
});
</script>
<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_HTML"></script>
</head>
<body>
<div id="content">
<div class="head">
<div class="title">
<p>
<a href="index.html">Ivanaf</a>
</p>
</div>
<menu>
<ul class="org-ul">
<li><a href="index.html">Home</a></li>
<li><a href="journal.html">Journal</a></li>
<li><a href="about.html">About</a></li>
<li><a href="resume.html">Resume</a></li>
<li><a href="portfolio.html">Portfolio</a></li>
<li><a href="contact.html">Contact</a></li>
<li><a href="projects_ideas.html">Messy Ideas</a></li>
</ul>
</menu>
</div>
<p>
</p><h1>
Simple proof weak master theorem
</h1><p>
</p>
<p>
<span class=page-date> <small>
2018-09-12, updated 2020-07-26 — <a href='journal.html#tech' class='tech tagbutton'>tech</a> <a href='journal.html#blog' class='blog tagbutton'>blog</a>   <a href="export_subtree_with_files.html">⇦Export subtree with files</a> – <a href="emacs_drag-drop_pdfs_paste_html_custom_templates.html">Emacs drag-drop pdfs, paste html, custom templates⇨</a>
</small> </span>
</p>
<nav id="table-of-contents">
<input id="toggle-toc" style="display: none; visibility: hidden;" type="checkbox">
<label for="toggle-toc">
<h2> <b> Table of Contents </b> </h2>
</label>
<div id="text-table-of-contents">
<ul>
<li><a href="#work_per_level">1. Work per level:</a></li>
<li><a href="#number_of_levels">2. Number of levels</a></li>
<li><a href="#total_work_on_the_tree">3. Total work on the tree</a></li>
<li><a href="#case_1_fracabc1">4. Case 1: \[\frac{a}{b^c}<1\]</a></li>
<li><a href="#case_2_fracabc1">5. Case 2: \[\frac{a}{b^c}=1\]</a></li>
<li><a href="#case_3_fracabc1">6. Case 3: \[\frac{a}{b^c}>1\]</a></li>
</ul>
</div>
</nav>
<p>
For a 006 student piazza question. Te student liked my answer so I decided to share!
</p>
<div id="outline-container-work_per_level" class="outline-2">
<h2 id="work_per_level"><span class="section-number-2">1</span> Work per level:</h2>
<div class="outline-text-2" id="text-1">
<p>
Suppose you have:
</p>
<p>
\[T(n) = a T(n/b) + n^c\]
</p>
<p>
The amount of work done on the root of the tree is:
</p>
<p>
\[n^c\].
</p>
<p>
The amount of work done in the next level is:
</p>
<p>
\[n^c \frac{a}{b^c}\]
</p>
<p>
so on the \(i^{th}\) level, considering the root to be level 0, is:
</p>
<p>
\[n^c \left(\frac{a}{b^c}\right)^i\]
</p>
</div>
</div>
<div id="outline-container-number_of_levels" class="outline-2">
<h2 id="number_of_levels"><span class="section-number-2">2</span> Number of levels</h2>
<div class="outline-text-2" id="text-2">
<p>
Given that the size of an element of the tree decreases by \(b\) in each level, e.g. \(n\) -> n/b, n/b^2…
</p>
<p>
An element of the tree will have size 1 at the level:
\[\log_bn\]
</p>
</div>
</div>
<div id="outline-container-total_work_on_the_tree" class="outline-2">
<h2 id="total_work_on_the_tree"><span class="section-number-2">3</span> Total work on the tree</h2>
<div class="outline-text-2" id="text-3">
<p>
The total amount of work on the tree is therefore:
</p>
<p>
\[\sum_{i=0}^{\log_bn} n^c \left(\frac{a}{b^c}\right)^i = n^c \sum_{i=0}^{\log_bn} \left(\frac{a}{b^c}\right)^i \]
</p>
<p>
This naturally leads to 3 cases:
</p>
<p>
\[ \left(\frac{a}{b^c}\right) >1\]
</p>
<p>
\[ \left(\frac{a}{b^c}\right) = 1\]
</p>
<p>
\[ \left(\frac{a}{b^c}\right) < 1\]
</p>
</div>
</div>
<div id="outline-container-case_1_fracabc1" class="outline-2">
<h2 id="case_1_fracabc1"><span class="section-number-2">4</span> Case 1: \[\frac{a}{b^c}<1\]</h2>
<div class="outline-text-2" id="text-4">
<p>
You have a geometric series of ratio < 1:
</p>
<p>
\[n^c \sum_{i=0}^{\log_bn} \left(\frac{a}{b^c}\right)^i \le n^c <br/> \sum_{i=0}^{\infty} \left(\frac{a}{b^c}\right)^i = n^c \frac{1}{1-\left(\frac{a}{b^c}\right)}\]
</p>
<p>
And this new term is just a constant
</p>
<p>
So:
</p>
<p>
\[\theta ( n^{c})\]
</p>
</div>
</div>
<div id="outline-container-case_2_fracabc1" class="outline-2">
<h2 id="case_2_fracabc1"><span class="section-number-2">5</span> Case 2: \[\frac{a}{b^c}=1\]</h2>
<div class="outline-text-2" id="text-5">
<p>
Now the amount of work per level is the same, so:
</p>
<p>
\[n^c \sum_{i=0}^{\log_bn} \left(\frac{a}{b^c}\right)^i= n^c \sum_{i=0}^{\log_bn} 1 = n^c \log_bn \]
</p>
</div>
</div>
<div id="outline-container-case_3_fracabc1" class="outline-2">
<h2 id="case_3_fracabc1"><span class="section-number-2">6</span> Case 3: \[\frac{a}{b^c}>1\]</h2>
<div class="outline-text-2" id="text-6">
<p>
The easiest way to deal with this case is to simply turn the tree upside down.
</p>
<p>
The amount of work done at the leaves of the tree is the same as the number of leaves on the tree, which is:
</p>
<p>
\[a^{\log_b n} = \left(b^{\log_ba} \right)^{\log_bn} = \left(b^{\log_bn} \right)^{\log_ba} = n^{\log_ba}\]
</p>
<p>
At every level above the leaves, the amound of work is multiplied by
</p>
<p>
\[\frac{1}{\frac{a}{b^c}} = \frac{b^c}{a}\]
</p>
<p>
So the total amount of work done in the tree is:
</p>
<p>
\[ \sum_{i=0}^{\log_bn} n^{\log_ba} \left(\frac{b^c}{a}\right)^i = n^{\log_ba} \sum_{i=0}^{\log_bn} \left(\frac{b^c}{a}\right)^i \]
</p>
<p>
\[\le n^{\log_ba} \sum_{i=0}^{\infty} \left(\frac{b^c}{a}\right)^i = n^{\log_ba} \frac{1}{1-\left(\frac{b^c}{a}\right)}\]
</p>
<p>
And similar to the first case, this is simply
</p>
<p>
\[\theta ( n^{\log_ba})\]
</p>
</div></div>
<br>
<div class="comments">
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'ivanaf'; // Required - Replace '<example>' with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
var showComments = function() {
var button = document.getElementById('comment-button')
button.style.display = 'none'
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
};
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<button id="comment-button" onclick="showComments()">Show comments</button>
</div>
<div><div>
</div>
</div>
</div>
<div id="postamble" class="status">
<p class="author">Author: Ivan Tadeu Ferreira Antunes Filho</p>
<p class="date">Date: 2022-07-23 Sat 05:11</p>
<p class="author">Github: <a href="https://github.com/itf/">github.com/itf</a></p>
<p class="creator">Made with <a href="https://www.gnu.org/software/emacs/">Emacs</a> 27.1 (<a href="https://orgmode.org">Org</a> mode 9.3) and <a href="https://github.com/itf/org-export-head">Org export head</a> </p>
</div>
</body>
</html>