summaryrefslogtreecommitdiff
path: root/260/CH8/EX8.3/8_3.sce
diff options
context:
space:
mode:
Diffstat (limited to '260/CH8/EX8.3/8_3.sce')
-rw-r--r--260/CH8/EX8.3/8_3.sce23
1 files changed, 23 insertions, 0 deletions
diff --git a/260/CH8/EX8.3/8_3.sce b/260/CH8/EX8.3/8_3.sce
new file mode 100644
index 000000000..0ab7c9bee
--- /dev/null
+++ b/260/CH8/EX8.3/8_3.sce
@@ -0,0 +1,23 @@
+//Eg-8.3
+//pg-369
+
+clear
+clc
+
+A = [2 3 1 4 5];
+
+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
+
+printf('Using the insertion sort method the arranged form of the given array\n')
+disp(A)
+