Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java in General
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Tim Cooke
Campbell Ritchie
paul wheaton
Ron McLeod
Devaka Cooray
Sheriffs:
Jeanne Boyarsky
Liutauras Vilda
Paul Clapham
Saloon Keepers:
Tim Holloway
Carey Brown
Piet Souris
Bartenders:
Forum:
Java in General
Selection Sort in Java
Sameera Liyanage
Greenhorn
Posts: 23
I like...
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
i was got a code as follow. can i know wether it is a selection sort or not?
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package algorithm; /** * * @author PC */ public class SelectionSort { private static int[] array={1,3,2,5,4,9,7,10,8,6}; public void printArray(){ for(int a:array){ System.out.print(a+" "); } } public void decendingOrder(){ int temp; for(int i=0;i<10;i++){ for(int j=0;j<10;j++){ if(array[i]>=array[j]){ temp=array[i]; array[i]=array[j]; array[j]=temp; } } } } public void acendingOrder(){ int temp; for(int i=0;i<10;i++){ for(int j=0;j<10;j++){ if(array[i]<=array[j]){ temp=array[i]; array[i]=array[j]; array[j]=temp; } } } } public static void main(String args[]){ SelectionSort ss=new SelectionSort(); ss.printArray(); System.out.println("\n====================================\n"); ss.decendingOrder(); ss.printArray(); System.out.println("\n====================================\n"); ss.acendingOrder(); ss.printArray(); System.out.println("\n====================================\n"); } }
Try to give something good to the world.
E Armitage
Rancher
Posts: 989
9
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
What do
you
think and why?
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
?
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
need help sorting Integer objects
Sorting alphabetic characters (using Array)
Bubble Sort Array, read from a text file.
I can NOT compile first class below
Please help in this selection sort
More...