Tuesday, May 22, 2012

Program to Implement Selection Sort in Java+Explanation

Selection sort is said to be an efficient algorithm when considering small computations involving limited memory/resource but it is quite inefficient when compared to other techniques when huge computations are required.Selection sort is said to be efficient for small list of items because of its simplicity.

The following steps Explains the working of the Selection sort Algorithm

  1. Obtain the Item with the Minimal value from a List/Collection of items
  2. Swap the item with the Item in the first position of the Collection/List
  3. Repeat the Process for the rest of the Items in the Collection

The Following is the Complete Program Source Code in Java for Implementing Selection Sort Algorithm
 import java.io.*;
import java.lang.*;
class array
 DataInputStream get;
 int a[];
 int i,j,n;
 void getdata()
   get=new DataInputStream(System.in);
   System.out.println("Enter the limit");
   a=new int[n];
   System.out.println("Enter the elements in the array");
 System.out.println("Elements in ascending order is:");
 System.out.print(" "+a[i]);
class selectionsort
 public static void main(String arg[])
  array obj=new array();

No comments:

Post a Comment

Which is the Best Photo Watermarking Software

Photo Theft is becoming more and more common in the web with the outburst of social websites like Facebook,Google Plus and Image sharing se...