Блог пользователя ziyistudy

Автор ziyistudy, история, 16 месяцев назад, По-английски

A. SwapSort

it's a quite easy problem within n<=1000. But I am wondering can we solve the problem in O(n), I have seen some people mention about it.

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
16 месяцев назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

The process of performing swaps via a cycle detection method can indeed be done in O(n). However, determining the sorted order using a general comparison-based algorithm will typically be O(nlogn) only ig. Therefore, unless you make additional assumptions (e.g., a limited range of values), the overall algorithm will be dominated by the sorting phase (O(nlogn)) rather than the swap phase (O(n)).

So ig nlogn