diff options
Diffstat (limited to '260/DEPENDENCIES/insertion_sort.sci')
-rw-r--r-- | 260/DEPENDENCIES/insertion_sort.sci | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/260/DEPENDENCIES/insertion_sort.sci b/260/DEPENDENCIES/insertion_sort.sci new file mode 100644 index 000000000..d6b5f5d32 --- /dev/null +++ b/260/DEPENDENCIES/insertion_sort.sci @@ -0,0 +1,14 @@ +function A = insertion_sort(A)
+ n = length(A);
+
+for(i = 2:n)
+ t = A(i);
+ j = i;
+ while((j > 1) & (A(j-1) > t))
+ A(j) = A(j-1);
+ j = j-1;
+ end
+ A(j) = t;
+end
+
+endfunction
\ No newline at end of file |