゜ヌトアルゎリズムIntermediate

カりンティング゜ヌト

各芁玠の出珟回数をカりントし、算術挔算を䜿甚しお䜍眮を決定する非比范゜ヌトアルゎリズムです。入力倀の範囲をkずしお、O(n+k)の時間蚈算量を達成したす。既知の限られた範囲内の敎数の゜ヌトに理想的です。基数゜ヌトの基瀎を圢成したす。

#sorting#linear-time#non-comparison#stable

Complexity Analysis

Time (Average)

O(n + k)

Expected case performance

Space

O(n + k)

Memory requirements

Time (Best)

O(n + k)

Best case performance

Time (Worst)

O(n + k)

Worst case performance

📚 CLRS Reference

Introduction to Algorithms•Chapter 8•Section 8.2

Step: 1 / 0
500ms
SlowFast
Keyboard Shortcuts
Space Play/Pause← → StepR Reset1-4 Speed

Real-time Statistics

Algorithm Performance Metrics

Progress0%
Comparisons
0
Swaps
0
Array Accesses
0
Steps
1/ 0

Algorithm Visualization

Step 1 of 0

Initialize array to begin

Default
Comparing
Swapped
Sorted

Code Execution

Currently executing
Previously executed

Implementation

Counting Sort - Algorithm Vision | Algorithm Vision