Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,26 @@
|
|||
function list = shellSort(list)
|
||||
|
||||
N = numel(list);
|
||||
increment = round(N/2);
|
||||
|
||||
while increment > 0
|
||||
|
||||
for i = (increment+1:N)
|
||||
temp = list(i);
|
||||
j = i;
|
||||
while (j >= increment+1) && (list(j-increment) > temp)
|
||||
list(j) = list(j-increment);
|
||||
j = j - increment;
|
||||
end
|
||||
|
||||
list(j) = temp;
|
||||
|
||||
end %for
|
||||
|
||||
if increment == 2 %This case causes shell sort to become insertion sort
|
||||
increment = 1;
|
||||
else
|
||||
increment = round(increment/2.2);
|
||||
end
|
||||
end %while
|
||||
end %shellSort
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
>> shellSort([4 3 1 5 6 2])
|
||||
|
||||
ans =
|
||||
|
||||
1 2 3 4 5 6
|
||||
Loading…
Add table
Add a link
Reference in a new issue