This commit is contained in:
krahets
2023-04-10 03:12:10 +08:00
parent dda68e47c1
commit 9393f5957c
35 changed files with 399 additions and 544 deletions

View File

@ -2085,7 +2085,7 @@
<p>然而实际上,<strong>统计算法的运行时间既不合理也不现实</strong>。首先,我们不希望预估时间和运行平台绑定,因为算法需要在各种不同的平台上运行。其次,我们很难获知每种操作的运行时间,这给预估过程带来了极大的难度。</p>
<h2 id="222">2.2.2. &nbsp; 统计时间增长趋势<a class="headerlink" href="#222" title="Permanent link">&para;</a></h2>
<p>「时间复杂度分析」采取了一种不同的方法,其统计的不是算法运行时间,<strong>而是算法运行时间随着数据量变大时的增长趋势</strong></p>
<p>“时间增长趋势”这个概念较为抽象,我们通过一个例子来加以理解。假设输入数据大小为 <span class="arithmatex">\(n\)</span>,给定三个算法 <code>A</code><code>B</code><code>C</code></p>
<p>“时间增长趋势”这个概念较为抽象,我们通过一个例子来加以理解。假设输入数据大小为 <span class="arithmatex">\(n\)</span> ,给定三个算法 <code>A</code> , <code>B</code> , <code>C</code></p>
<ul>
<li>算法 <code>A</code> 只有 <span class="arithmatex">\(1\)</span> 个打印操作,算法运行时间不随着 <span class="arithmatex">\(n\)</span> 增大而增长。我们称此算法的时间复杂度为「常数阶」。</li>
<li>算法 <code>B</code> 中的打印操作需要循环 <span class="arithmatex">\(n\)</span> 次,算法运行时间随着 <span class="arithmatex">\(n\)</span> 增大呈线性增长。此算法的时间复杂度被称为「线性阶」。</li>
@ -2599,7 +2599,7 @@ T(n) &amp; = n^2 + n &amp; \text{偷懒统计 (o.O)}
</div>
</div>
<h3 id="2">2) 判断渐近上界<a class="headerlink" href="#2" title="Permanent link">&para;</a></h3>
<p><strong>时间复杂度由多项式 <span class="arithmatex">\(T(n)\)</span> 中最高阶的项来决定</strong>。这是因为在 <span class="arithmatex">\(n\)</span> 趋于无穷大时,最高阶的项将发挥主导作用,其项的影响都可以被忽略。</p>
<p><strong>时间复杂度由多项式 <span class="arithmatex">\(T(n)\)</span> 中最高阶的项来决定</strong>。这是因为在 <span class="arithmatex">\(n\)</span> 趋于无穷大时,最高阶的项将发挥主导作用,其项的影响都可以被忽略。</p>
<p>以下表格展示了一些例子,其中一些夸张的值是为了强调“系数无法撼动阶数”这一结论。当 <span class="arithmatex">\(n\)</span> 趋于无穷大时,这些常数变得无足轻重。</p>
<div class="center-table">
<table>