Sorting

James·2023년 3월 6일
0

Data Structure & Algorithm

목록 보기
10/16
post-custom-banner

Sorting Characteristics

AlgorithmComparisonIn-placeStableWorst-caseAverage-case
Insertion sortYesYesYesΘ(n2)\Theta(n^2)Θ(n2)\Theta(n^2)
Merge sortYesNoYesΘ(nlgn)\Theta(nlgn)Θ(nlgn)\Theta(nlgn)
Heap sortYesYesNoO(nlgn)O(nlgn)-
Quick sortYesYesNoΘ(n2)\Theta(n^2)Θ(nlgn) (expected)\Theta(nlgn)\ (expected)
Counting sortNoNoYesΘ(n+k)\Theta(n+k)Θ(n+k)\Theta(n+k)
Radix sortNoNoYesΘ(d(n+k))\Theta(d(n+k))Θ(d(n+k))\Theta(d(n+k))
Bucket sortNoNoYesΘ(n2)\Theta(n^2)Θ(n) (average case)\Theta(n)\ (average\ case)

Comparison Sort

  • Input array의 elements간 compare operation을 수행하는지.

In-place Sort

  • Input data structure에 대한 constant storage만을 사용하는지.

Stable Sort

  • Input data structure의 sorted key를 유지하는 방식인지.
profile
System Software Engineer
post-custom-banner

0개의 댓글