Thread: recursive selection sort..

  1. #31
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,059
    You don't need recSelSort() and your swap() is misplaced. swap() belongs inside recFindMin() and selSort() should be used to move the min element forward but instead you're decrementing it.
    Code:
    selSort(array,i-1,length); /* i will never reach length which is the top level condition */

  2. #32
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    ok ill try to implement it

  3. #33
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,059
    IMO the only functions you need to get the entire job done using only recursion are listed below with minor changes as in
    Code:
    void selSort(int array[], int i ,int length);
    void swap(int num[],int i,int j);
    int recFindMin(int array[], int index, int length);
    selSort() is the top level function; its index i increments while length remains the same.
    In recFindMin() index i remains the same while length decrements.

  4. #34
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,059
    In case you are interested here's a pretty good guide to recursion http://faq.cprogramming.com/cgi-bin/...&id=1073086407
    Any luck nailing down the current recursion sort?

  5. #35
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    i solved it

  6. #36
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,059
    Quote Originally Posted by transgalactic2 View Post
    i solved it
    just curious to see what the final solution looks like?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Insertion and selection sort
    By Dashing Boy in forum C Programming
    Replies: 4
    Last Post: 08-29-2006, 04:42 PM
  2. recursive quick sort - stack overflow
    By Micko in forum C Programming
    Replies: 9
    Last Post: 01-01-2005, 05:51 PM
  3. Recursive Array Sort
    By Nakeerb in forum C++ Programming
    Replies: 3
    Last Post: 12-13-2002, 08:27 PM
  4. recursive selection sort function
    By Cornelius in forum C Programming
    Replies: 3
    Last Post: 11-08-2002, 04:12 PM
  5. selection sort records of chars
    By hew in forum C++ Programming
    Replies: 8
    Last Post: 04-23-2002, 03:49 PM