mirror of
https://github.com/krahets/hello-algo.git
synced 2026-08-10 02:50:59 +00:00
deploy
This commit is contained in:
@@ -3918,7 +3918,7 @@
|
||||
</div>
|
||||
<h2 id="1152-algorithm-features">11.5.2 Algorithm features<a class="headerlink" href="#1152-algorithm-features" title="Permanent link">¶</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>
|
||||
|
||||
Reference in New Issue
Block a user