mirror of
https://github.com/krahets/hello-algo.git
synced 2026-07-20 10:36:09 +00:00
deploy
This commit is contained in:
@@ -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 -->
|
||||
|
||||
Reference in New Issue
Block a user