This commit is contained in:
krahets
2023-12-11 00:57:05 +08:00
parent 0dae0bcf31
commit 68eab8e7c1
6 changed files with 109 additions and 109 deletions
+1 -1
View File
@@ -4170,7 +4170,7 @@ x_k = \lfloor\frac{x}{d^{k-1}}\rfloor \bmod d
<ul>
<li><strong>时间复杂度 <span class="arithmatex">\(O(nk)\)</span></strong>:设数据量为 <span class="arithmatex">\(n\)</span>、数据为 <span class="arithmatex">\(d\)</span> 进制、最大位数为 <span class="arithmatex">\(k\)</span> ,则对某一位执行计数排序使用 <span class="arithmatex">\(O(n + d)\)</span> 时间,排序所有 <span class="arithmatex">\(k\)</span> 位使用 <span class="arithmatex">\(O((n + d)k)\)</span> 时间。通常情况下,<span class="arithmatex">\(d\)</span><span class="arithmatex">\(k\)</span> 都相对较小,时间复杂度趋向 <span class="arithmatex">\(O(n)\)</span></li>
<li><strong>空间复杂度 <span class="arithmatex">\(O(n + d)\)</span>、非原地排序</strong>:与计数排序相同,基数排序需要借助长度为 <span class="arithmatex">\(n\)</span><span class="arithmatex">\(d\)</span> 的数组 <code>res</code><code>counter</code></li>
<li><strong>稳定排序</strong>计数排序相同</li>
<li><strong>稳定排序</strong>计数排序稳定时,基数排序也稳定;当计数排序不稳定时,基数排序无法保证得到正确的排序结果</li>
</ul>
<!-- Source file information -->