This commit is contained in:
krahets
2024-07-30 16:54:47 +08:00
parent 8fb4fdc14c
commit 55b91eb967
140 changed files with 426 additions and 1278 deletions
+1 -1
View File
@@ -3918,7 +3918,7 @@
</div>
<h2 id="1152-algorithm-features">11.5.2 &nbsp; Algorithm features<a class="headerlink" href="#1152-algorithm-features" title="Permanent link">&para;</a></h2>
<ul>
<li><strong>Time complexity of <span class="arithmatex">\(O(n \log n)\)</span>, adaptive sorting</strong>: In average cases, the recursive levels of pivot partitioning are <span class="arithmatex">\(\log n\)</span>, and the total number of loops per level is <span class="arithmatex">\(n\)</span>, using <span class="arithmatex">\(O(n \log n)\)</span> time overall. In the worst case, each round of pivot partitioning divides an array of length <span class="arithmatex">\(n\)</span> into two sub-arrays of lengths <span class="arithmatex">\(0\)</span> and <span class="arithmatex">\(n - 1\)</span>, reaching <span class="arithmatex">\(n\)</span> recursive levels, and using <span class="arithmatex">\(O(n^2)\)</span> time overall.</li>
<li><strong>Time complexity of <span class="arithmatex">\(O(n \log n)\)</span>, non-adaptive sorting</strong>: In average cases, the recursive levels of pivot partitioning are <span class="arithmatex">\(\log n\)</span>, and the total number of loops per level is <span class="arithmatex">\(n\)</span>, using <span class="arithmatex">\(O(n \log n)\)</span> time overall. In the worst case, each round of pivot partitioning divides an array of length <span class="arithmatex">\(n\)</span> into two sub-arrays of lengths <span class="arithmatex">\(0\)</span> and <span class="arithmatex">\(n - 1\)</span>, reaching <span class="arithmatex">\(n\)</span> recursive levels, and using <span class="arithmatex">\(O(n^2)\)</span> time overall.</li>
<li><strong>Space complexity of <span class="arithmatex">\(O(n)\)</span>, in-place sorting</strong>: In completely reversed input arrays, reaching the worst recursion depth of <span class="arithmatex">\(n\)</span>, using <span class="arithmatex">\(O(n)\)</span> stack frame space. The sorting operation is performed on the original array without the aid of additional arrays.</li>
<li><strong>Non-stable sorting</strong>: In the final step of pivot partitioning, the pivot may be swapped to the right of equal elements.</li>
</ul>