summaryrefslogtreecommitdiff
path: root/1034/CH7/EX7.4/7s4.sce
diff options
context:
space:
mode:
Diffstat (limited to '1034/CH7/EX7.4/7s4.sce')
-rwxr-xr-x1034/CH7/EX7.4/7s4.sce22
1 files changed, 22 insertions, 0 deletions
diff --git a/1034/CH7/EX7.4/7s4.sce b/1034/CH7/EX7.4/7s4.sce
new file mode 100755
index 000000000..0d7db85a0
--- /dev/null
+++ b/1034/CH7/EX7.4/7s4.sce
@@ -0,0 +1,22 @@
+clear;
+clc;
+disp("Example 7.4");
+function[a1]=insertion(a,n)
+ for k=1:n
+ y=a(k);
+ i=k;
+ while(i>=1)
+ if(y<a(i))
+ a(i+1)=a(i);
+ a(i)=y;
+ end
+ i=i-1;
+ end
+ end
+ a1=a;
+ disp(a1,"Sorted array is:");
+endfunction
+//Calling Routine:
+a=[3 1 2]
+disp(a,"Given Array");
+a1=insertion(a,3) \ No newline at end of file