Results 1 to 3 of 3
  1. #1
    Metastar's Avatar
    Metastar is offline Member
    Join Date
    Jul 2010
    Posts
    62
    Rep Power
    0

    Default Is this a Selection Sort?

    Just wanting to verify that this is a Selection Sort

    Java Code:
    public void selectionSort()
        {
            int out, in, min;
    
            for(out=0; out < reg4ArrList.size()-1; out++)
            {
                for(in=out+1; in < reg4ArrList.size(); in++)
                {
                    min = out;
    
                    if(reg4ArrList.get(in).getCountryName().compareToIgnoreCase
                            (reg4ArrList.get(min).getCountryName()) < 0)
                    {
                        min = in;
                        swap(min, out);
                    }//end if
                }//end inner for
            }//end outer for
        }//end selectionSort()
    
        private void swap(int i, int j)
        {
            Country temp1 = reg4ArrList.get(i);
            reg4ArrList.set(i, reg4ArrList.get(j));
            reg4ArrList.set(j, temp1);
    
        }//end swap()

  2. #2
    joshdgreen's Avatar
    joshdgreen is offline Senior Member
    Join Date
    Oct 2010
    Location
    Colorado Springs, CO
    Posts
    212
    Rep Power
    4

    Default

    Looks like one to me :)
    Sincerely, Joshua Green
    Please REP if I help :)

  3. #3
    Metastar's Avatar
    Metastar is offline Member
    Join Date
    Jul 2010
    Posts
    62
    Rep Power
    0

Similar Threads

  1. Problem with selection sort
    By Metastar in forum New To Java
    Replies: 6
    Last Post: 10-21-2010, 02:18 AM
  2. Selection Sort recursive java code
    By myst in forum New To Java
    Replies: 3
    Last Post: 07-12-2010, 10:08 AM
  3. selection sort
    By mayhewj7 in forum New To Java
    Replies: 1
    Last Post: 04-29-2009, 12:40 AM
  4. write a selection sort without having numerous variable?
    By seandingobat in forum New To Java
    Replies: 6
    Last Post: 10-28-2008, 02:33 PM
  5. Selection sort in Java
    By Java Tip in forum Algorithms
    Replies: 0
    Last Post: 04-15-2008, 07:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •