mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-03-23 05:12:40 +08:00
Documentation for db3f9d3406
This commit is contained in:
@@ -157,15 +157,15 @@ Functions</h2></td></tr>
|
||||
<div class="line">x = y;</div>
|
||||
<div class="line">y = z;</div>
|
||||
</div><!-- fragment --><p>The above process is a typical displacement process. When x assigns the value to x, the old value of x is lost. That's why we created a variable z to create the first value of the value of x, and finally, we have assigned to y.</p>
|
||||
<h2><a class="anchor" id="autotoc_md110"></a>
|
||||
<h2><a class="anchor" id="autotoc_md111"></a>
|
||||
Bubble Sort Algorithm Analysis (Best Case - Worst Case - Average Case)</h2>
|
||||
<h3><a class="anchor" id="autotoc_md111"></a>
|
||||
<h3><a class="anchor" id="autotoc_md112"></a>
|
||||
Best Case</h3>
|
||||
<p>Bubble Sort Best Case Performance. \(O(n)\). However, you can't get the best status in the code we shared above. This happens on the optimized bubble sort algorithm. It's right down there.</p>
|
||||
<h3><a class="anchor" id="autotoc_md112"></a>
|
||||
<h3><a class="anchor" id="autotoc_md113"></a>
|
||||
Worst Case</h3>
|
||||
<p>Bubble Sort Worst Case Performance is \(O(n^{2})\). Why is that? Because if you remember Big O Notation, we were calculating the complexity of the algorithms in the nested loops. The \(n * (n - 1)\) product gives us \(O(n^{2})\) performance. In the worst case all the steps of the cycle will occur.</p>
|
||||
<h3><a class="anchor" id="autotoc_md113"></a>
|
||||
<h3><a class="anchor" id="autotoc_md114"></a>
|
||||
Average Case</h3>
|
||||
<p>Bubble Sort is not an optimal algorithm. In average, \(O(n^{2})\) performance is taken.</p>
|
||||
<dl class="section author"><dt>Author</dt><dd><a href="https://github.com/Deepak-j-p" target="_blank">Deepak</a> </dd>
|
||||
|
||||
Reference in New Issue
Block a user