Graph for Sorting Plotted using R

The following  graph shows the time details to execute 
a sorting algorithm written in python.Array size for sort is 200.

The values for plotting the above graph is taken 
from the following readings.
Sat May 24 18:48:25 IST 2014

real	0m0.032s
user	0m0.028s
sys	0m0.000s

real	0m0.027s
user	0m0.020s
sys	0m0.004s

real	0m0.029s
user	0m0.024s
sys	0m0.000s

real	0m0.030s
user	0m0.024s
sys	0m0.000s

real	0m0.027s
user	0m0.020s
sys	0m0.000s

Graph for Sorting plotted using R

The following  graph shows the time details to execute 
a sorting algorithm written in python.


The values for plotting the above graph is taken 
from the following readings.
Fri May 16 21:36:17 IST 2014

real	0m0.019s
user	0m0.016s
sys	0m0.000s

real	0m0.021s
user	0m0.016s
sys	0m0.004s

real	0m0.024s
user	0m0.020s
sys	0m0.000s

real	0m0.020s
user	0m0.012s
sys	0m0.004s

real	0m0.024s
user	0m0.012s
sys	0m0.008s

R shell session to plot a Graph

The following is a R shell session to plot a graph.

$R

R version 3.0.3 (2014-03-06) -- "Warm Puppy"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> timereal  timeuser  timesys  timedata  png(filename="barplot-array-size-100-python.png")
> barplot(timedata,col=rainbow(5))
Fontconfig warning: "/etc/fonts/conf.d/65-droid-sans-fonts.conf", line 103: Having multiple values in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/65-droid-sans-fonts.conf", line 138: Having multiple values in  isn't supported and may not work as expected
> dev.off()
null device 
          1 
> 

bubble(think so) sort in python programming language

# bubblesort attempted to be ported to python by
# Jeffrin Jose T <ahiliation@yahoo.co.in>
# from bubble.php by # detour@metalshell.com # License : GPL.

 

array_size = 20;

import random
result = []

# hash values of numbers between -5 to 256 are the same as the
# numbers themselves. So, whatever may be the order, set will have them
# in the sorted order. So, `result` cannot be a `set` here.

for x in range (0, 20):
    num = random.randint(0, 20)
    while num in result:
        num = random.randint(0, 40)
    result.append(num)
print result


for x in range (0,array_size):
    for y in range (0,array_size):
        if result[x] < result[y]:
            hold = result[x]
            result[x] = result[y]
            result[y] = hold


for x in range (0,array_size):
    print result[x]

How to write a shell script to find the greatest among three numbers ?

#!/bin/bash
#
# Linux Shell Scripting Tutorial 1.05r3, Summer-2002
#
# Written by Vivek G. Gite <vivek@nixcraft.com>
# modified by Jeffrin Jose T. <ahiliation@yahoo.co.in>
# Latest version can be found at http://www.nixcraft.com/
#
# Q2. Script to find out biggest number
#
# Algo:
# 1) START: Take three nos as n1,n2,n3.
# 2) Is n1 is greater than n2 and n3, if yes
# print n1 is bigest no goto step 5, otherwise goto next step
# 3) Is n2 is greater than n1 and n3, if yes
# print n2 is bigest no goto step 5, otherwise goto next step
# 4) Is n3 is greater than n1 and n2, if yes
# print n3 is bigest no goto step 5, otherwise goto next step
# 5) END
#
#

if [ $# -ne 3 ]
then
echo "$0: number1 number2 number3 are not given" >&2
exit 1
fi
n1=$1
n2=$2
n3=$3
if [ $n1 -gt $n2 ] && [ $n1 -gt $n3 ]
then
echo "$n1 is the Biggest number"
elif [ $n2 -gt $n1 ] && [ $n2 -gt $n3 ]
then
echo "$n2 is the Biggest number"
elif [ $n3 -gt $n1 ] && [ $n3 -gt $n2 ]
then
echo "$n3 is the Biggest number"
elif [ $1 -eq $2 ] && [ $1 -eq $3 ] && [ $2 -eq $3 ]
then
echo "All the three numbers are equal"
else
echo "I can not figure out which number is bigger"
fi

#
# ./ch.sh: vivek-tech.com to nixcraft.com referance converted using this tool
# See the tool at http://www.nixcraft.com/uniqlinuxfeatures/tools/
#

pr – convert text files for printing

The following shows a command line session with pr 
command which helps in displaying contents of a file
in shell scripts.

$cat lkg.txt 
A for Apple
B for Ball
C for Cat
D for Donkey
E for Elephant
F for Fox
G for Goat
H for Horse
I for Insect
$pr -l 10 lkg.txt 
A for Apple
B for Ball
C for Cat
D for Donkey
E for Elephant
F for Fox
G for Goat
H for Horse
I for Insect
$