Results 1 to 6 of 6
Like Tree1Likes
  • 1 Post By gimbal2

Thread: Making selection sort into a recursive method.

  1. #1
    Mleclerc182 is offline Member
    Join Date
    Sep 2012
    Posts
    3
    Rep Power
    0

    Default Making selection sort into a recursive method.

    How would I modify this version of a selection sort into a recursive method?

    public static void selectionSortRecursive(Comparable [] list, int n)

    {
    int min;
    Comparable temp;

    for(int index =0; index < n-1; index++){
    min = index;
    for(int scan= index+1; scan<list.length; scan++)

    if (list[scan].compareTo(list[min])< 0)
    min = scan;
    temp = list[min];
    list[min]= list[index];
    list[index]=temp;
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: Making selection sort into a recursive method.

    You didn't bother to return to the thread you started two years ago. Why should we expect any better behavior this time round?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Making selection sort into a recursive method.

    Whoa, you're a harsh law enforcer :) A one time offense two years ago and then still the whip is cracked. I pity the fool who commits minor forum abuse within the same week.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Making selection sort into a recursive method.

    Quote Originally Posted by gimbal2 View Post
    Whoa, you're a harsh law enforcer :)
    Yeah.. Isn't it great!

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  5. #5
    Mleclerc182 is offline Member
    Join Date
    Sep 2012
    Posts
    3
    Rep Power
    0

    Default Re: Making selection sort into a recursive method.

    Quote Originally Posted by DarrylBurke View Post
    You didn't bother to return to the thread you started two years ago. Why should we expect any better behavior this time round?

    db
    Well, sorry about that. But I'm here now so would you mind helping a novice programmer out? I couldn't find any other examples exactly like this online and I am having trouble with the logic myself.

  6. #6
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Making selection sort into a recursive method.

    Examples of what exactly?

    I hope you are looking for information on how recursive methods work and not for an example of your precise requirement which you can copy from. A Google for "java recursive method" returns plenty of examples, most with proper explanations too.
    DarrylBurke likes this.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Selection sort method?
    By Propinquity in forum New To Java
    Replies: 2
    Last Post: 03-05-2014, 10:46 AM
  2. Selection sort to quick sort conversion without Nodes?
    By VettesRus in forum New To Java
    Replies: 0
    Last Post: 11-03-2013, 02:54 AM
  3. Recursive method to sort array
    By artur in forum New To Java
    Replies: 2
    Last Post: 03-19-2012, 12:49 PM
  4. merge sort with recursive method (need help badlly!!)
    By zetalore in forum Advanced Java
    Replies: 0
    Last Post: 01-08-2011, 07:10 PM
  5. Selection Sort recursive java code
    By myst in forum New To Java
    Replies: 3
    Last Post: 07-12-2010, 10:08 AM

Tags for this Thread

Posting Permissions

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