SHORTING
1.)Selection Sort:--
class sel Shot
{
public static void main(string args[]){
int a[] = { };
int i,j.t;
int n= a.length;
system.out.println("Array");
for(i=0; i<n; i++)
{
system.out.println(a[i] + "\t")
}
for(i=0; i<n; i++)
{
for(j=i+1; j<n; j++)
{
if(a[i] > a[j])
{
t = a[i];
a[i] = a[j];
a[j] = t;
}
}
}
System.out.println("\n shorted list");
for(i=o; i<n; i++)
system.out.print( a[i] + "\t");
}
}
}
system.out.println("\n shorted array")
for(i=o; i<n; i++)
system.out.print(a[i]+ "\t");
}
}
}
2.) Insertion Short:--
class inser Shot
{
public static void main(string args[]){
int a[] = { };
int i,j.t;
int n= a.length;
system.out.println("Array");
for(i=0; i<n; i++)
{
system.out.println(a[i] + "\t")
}
for(i=0; i<n; i++)
{
for(j=i; j<0; j--)
{
if(a[j-1] > a[j])
{
t = a[j-1];
a[j-1] = a[j];
a[j] = t;
}
}
}
system.out.println("\n shorted array")
for(i=o; i<n; i++)
system.out.print(a[i]+ "\t");
}
}
}
system.out.println("\n shorted array")
for(i=o; i<n; i++)
system.out.print(a[i]+ "\t");
}
}
}
2.) Bubble Short:--
class bub Shot
{
public static void main(string args[]){
int a[] = { };
int i,j.t;
int n= a.length;
system.out.println("Array");
for(i=0; i<n; i++)
{
system.out.println(a[i] + "\t")
}
for(i=0; i<n; i++)
{
for(j=0; j<n-1; j++)
{
if(a[j] > a[j+1])
{
t = a[j];
a[j] = a[j+1];
a[j+1] = t;
}
}
}
system.out.println("\n shorted array")
for(i=o; i<n; i++)
system.out.print(a[i]+ "\t");
}
}
}
system.out.println("\n shorted array")
for(i=o; i<n; i++)
system.out.print(a[i]+ "\t");
}
}
}