Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
24 37 46 11 85 47 33 66 22 84 95 55 14 09 76 35
24 22 37 84 46 95 11 55 85 14 47 09 33 76 66 35
22 37 46 11 14 09 33 35 24 84 95 55 85 47 76 66
22 14 24 85 37 09 84 47 46 33 95 76 11 35 55 66
14 09 33 11 22 37 46 35 24 47 76 55 85 84 95 66
14 33 22 46 24 76 85 95 09 11 37 35 47 55 84 66
14 09 22 11 24 35 33 37 46 47 76 55 85 66 95 84
14 09 22 11 24 35 33 37 46 47 76 55 85 66 95 84
Sorted List L
K1 K2 K3 K4 K5 K6 K7 K8 K9 K10 K11 K12 K13 K14 K15 K16
09 11 14 22 24 33 35 37 46 47 55 66 76 84 85 95
Shell Sort
Trace the shell sort procedure on the
unordered list L of keys given by
L={24,37,46,11,85,47,33,66,22,84,95,55,14,09
,76,35} for an increment sequence
{h3, h2, h1, h0}={7,5,3,1}
Shell Sort
Algorithm for Shell sort
Procedure shell_sort(L,n,H)
/* L[1:n] is the unordered list of keys to be shell sorted.
(L={K1,K2,Kj,..Kn}) H={ht,ht-1,ht-2,h2,h1,h0) is the
sequence of increments */
For each hj H do
Insertion sort the sublist of elements in L[1:n]
Which are hj units apart, such that
L[i]<= L[i+hj ], for 1<=i<=N-hj
End
Print(L)
End Shell_sort
Analysis of Shell Sort
The analysis of shell sort is dependent on a
given choice of increments
Since there is no best possible sequence of
increments that has been formulated,
especially for large values of n ( the size of the
list L), the time complexity of shell sort is
completely resolved