public static TimeSpan ShellSort(T[] items) where T : IComparable { DateTime start = DateTime.Now; int inc = (int)Math.Round(items.Length / 2d); while (inc > 0) { for (int i = inc; i < items.Length; i++) { T temp = items[i]; int j = i; while (j >= inc && items[j - inc].CompareTo(temp) > 0) { items[j] = items[j - inc]; j -= inc; } items[j] = temp; } inc = (int)Math.Round(inc / 2.2d); } return DateTime.Now - start; }
'Software Development > Computer Algorithm Collection' 카테고리의 다른 글
| 선택 정렬 - Smooth Sort (0) | 2010/04/13 |
|---|---|
| 선택 정렬 - Heap Sort #1 (힙 정렬 #1) (0) | 2010/04/13 |
| 삽입 정렬 - Shell Sort (외곽 정렬) (0) | 2010/04/13 |
| 삽입 정렬 - Insertion Sort (삽입 정렬) (0) | 2010/04/13 |
| 교환 정렬 - Quick Sort (퀵 정렬) (0) | 2010/04/13 |
| 교환 정렬 - Odd-Even Sort (홀수-짝수 정렬) (0) | 2010/04/13 |