WRITE A SHELL SCRIPT TO PERFORM BUBBLE SORT
echo “Enter the number
of element:”
read n
i=1
while test $i -le $n
do
var=a$i
echo “Enter the
number:”
read $var
i=`expr $i + 1`
done
i=1
while test $i -le `expr
$n - 1`
do
while test $j -le `expr
$n -$i`
do
num1=a$j
num2=a`expr $j + 1`
if eval test \$$num1
–gt \$$num2
then
eval t=\$$num1
eval $num1=\$$num2
eval $num2=$t
fi
j=`expr $j + 1`
done
i=expr $i + 1`
done
echo “The sorted list
is:”
i=1
while test $i -ne $n
do
num=a$i
eval echo \$$num
i=`expr $i + 1`
done
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment