Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Difficult recursion problem in C

  1. Jun 19, 2009 #1
    Hi, everybody.
    I really need your help with this question that giving me no sleep at nights. :(

    no loops and no pointers, and No STATIC can be used.
    Write a recursive function that fills the given character
    array with all possible given-size subsets of characters in
    given word, separated by commas

    does anyone have an idea?
    Last edited: Jun 20, 2009
  2. jcsd
  3. Jun 19, 2009 #2

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    No pointers? The function takes two pointers as arguments!

    The order of the desired output strongly indicates you should be looking at a depth first recursion technique.
  4. Jun 19, 2009 #3
    it means no using *types, calling to r as an address in the array is fine.
    what is first recursion technique can you add an exmple?
  5. Jun 19, 2009 #4
    The subsets of size m of the numbers 1,2,...n are:
    1, added at the beginning of the subsets of size m-1 of the numbers 2,3,...,n
    followed by the subsets of size m of 2,...,n
    This doesn't consider the base cases--base cases are when m=0, or when the range of numbers considered is empty.
    Last edited: Jun 19, 2009
  6. Jun 19, 2009 #5

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    That's a bit too much help, mXSCNT.
  7. Jun 19, 2009 #6
    Alright, I'll delete the second part.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Discussions: Difficult recursion problem in C
  1. Recursion in C (Replies: 12)

  2. C++ is crazy difficult. (Replies: 26)