summaryrefslogtreecommitdiff
path: root/260/CH8/EX8.5/8_5.sce
diff options
context:
space:
mode:
Diffstat (limited to '260/CH8/EX8.5/8_5.sce')
-rw-r--r--260/CH8/EX8.5/8_5.sce38
1 files changed, 38 insertions, 0 deletions
diff --git a/260/CH8/EX8.5/8_5.sce b/260/CH8/EX8.5/8_5.sce
new file mode 100644
index 000000000..f8eb3ada4
--- /dev/null
+++ b/260/CH8/EX8.5/8_5.sce
@@ -0,0 +1,38 @@
+//Eg-8.5
+//pg-373
+
+clear
+clc
+
+A = [125 130 141 126 116 112 135 137 119 120 128 143 115 123 133];
+
+n = length(A);
+
+h = 3
+
+T = A
+j = 1
+
+exec('insertion_sort.sci')
+
+while(h>0)
+
+a = 1
+b = 0
+
+for(i = 1:h)
+ b = b + length(A(i:h:n))
+ T(j+1,a:b) = insertion_sort(A(i:h:n))
+ a = a + length(A(i:h:n))
+end
+
+h = floor(h/2)
+j = j+1
+
+end
+
+printf('Sorting the given data using Shell sort\n')
+disp(T(j,:))
+
+
+ \ No newline at end of file