Сортирање поређењем — разлика између измена

Садржај обрисан Садржај додат
Ред 159:
|}
<div class="thumbcaption">
 
Above: A comparison of the lower bound <math>\lceil\log_2(n!)\rceil</math> to the actual minimum number of comparisons (from {{OEIS2C|id=A036604}}) required to sort a list of ''n'' items. Below: Using [[Stirling's approximation]], this lower bound is well-approximated by <math>n \log_2 n - \frac{n} {\ln 2}</math>.</div>
Изнад: Поређење доње границе <math>\lceil\log_2(n!)\rceil</math> са стварни минимумом броја поређења (од {{OEIS2C|id=A036604}}) који је неопходан за сортирање листе од ''n'' елемената. Испод: Помоћу Стирлингове апроксимације, ова доња граница је оптимизована са <math>n \log_2 n - \frac{n} {\ln 2}</math>.</div>
</div>
</div>
 
Број поређења који овај алгоритам захтева повећање у пропорцији са <math>n\log(n)</math>, где <math>n</math> је број елемената за сортирање. Ова граница је асимптотички мала.
The number of comparisons that a comparison sort algorithm requires increases in proportion to <math>n\log(n)</math>, where <math>n</math> is the number of elements to sort. This bound is [[Asymptotic computational complexity|asymptotically tight]].
 
Given a list of distinct numbers (we can assume this because this is a worst-case analysis), there are ''n'' [[factorial]] permutations exactly one of which is the list in sorted order. The sort algorithm must gain enough information from the comparisons to identify the correct permutation. If the algorithm always completes after at most ''f''(''n'') steps, it cannot distinguish more than 2<sup>''f''(''n'')</sup> cases because the keys are distinct and each comparison has only two possible outcomes. Therefore,