blob: 0ab7c9bee3824199ad71de2961c4424b96a00123 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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)
|