Thread: Functions and recursion with permutations and combinations. Completely lost

  1. #1
    Registered User
    Join Date
    Sep 2014
    Posts
    18

    Functions and recursion with permutations and combinations. Completely lost

    So in my C Programming class, we just got into functions and our assignment is to "test our ability to utilize functions and recursion."

    The actual assignment is:

    "For this assignment, you will have to create functions to compute permutations and combinations. Unlike other assignments, you will not be graded on your main function. I will call your functions from a main function I create to test the values. Due to this, I will provide the required method signatures.unsigned long Factorial( unsigned n );
    unsigned long Exponential( unsigned base, unsigned power );

    unsigned long PermutationsWithRepetitions( unsigned n, unsigned r );
    unsigned long PermutationsWithoutRepetitions( unsigned n, unsigned r );

    unsigned long CombinationsWithRepetitions( unsigned n, unsigned r );
    unsigned long CombinationsWithoutRepetitions( unsigned n, unsigned r );


    https://uah.instructure.com/equation...2529%2521%257D
    https://uah.instructure.com/equation...3A%253Dn%255Er
    https://uah.instructure.com/equation...2529%2521%257D
    https://uah.instructure.com/equation...2529%2521%257D"

    I haven't missed a class, I've taken notes, and I'm completely lost. Is this worded badly or am I just missing something? I have absolutely no idea what I'm supposed to do. Like I see the raw formulas and the signatures, but I don't know what he's asking me to do with them. He doesn't go by our book either, and the powerpoints don't clear anything up. I've tried to figure out what I'm missing but this is kind of my last leg, does anyone know what the heck I'm supposed to do?



    Last edited by Spritesgud; 03-25-2015 at 01:48 PM.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,181
    Do you know what are permutations and combinations, and what "with repetitions" and "without repetitions" mean? You almost certainly should know how to write functions by now, but do you understand recursion and have you experimented with your own recursive functions outside the examples shown to you?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Sep 2014
    Posts
    18
    Quote Originally Posted by laserlight View Post
    Do you know what are permutations and combinations, and what "with repetitions" and "without repetitions" mean? You almost certainly should know how to write functions by now, but do you understand recursion and have you experimented with your own recursive functions outside the examples shown to you?
    Recursion is when a function calls iteself, but I've never had any practice with it. Combinations and permutations are like the different options (I think?) And permutations 123 and 321 are different, but combinations they are the same. What would be a good place to start for some recursion practice?

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,181
    Quote Originally Posted by Spritesgud
    What would be a good place to start for some recursion practice?
    Typical starting points would be implementing things like a program that computes factorials with recursion, or a Fibonacci sequence generator that uses recursion instead of iteration or an approximation formula. You can rewrite loops to use recursion instead: though you won't normally do this, it can be a form of practice. If you have worked with tree structures, recursion is often a natural fit.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Completely lost...
    By tmac619619 in forum C Programming
    Replies: 8
    Last Post: 11-11-2012, 03:39 AM
  2. completely lost
    By jonesk1978 in forum C++ Programming
    Replies: 9
    Last Post: 04-06-2012, 03:01 PM
  3. Unique combinations of groups in C++ w/ recursion
    By nezitx in forum C++ Programming
    Replies: 2
    Last Post: 04-30-2010, 10:06 PM
  4. recursion? combinations of numbers
    By ominub in forum C Programming
    Replies: 2
    Last Post: 10-02-2009, 03:36 PM
  5. Completely lost in C#
    By rvbalplaya in forum C# Programming
    Replies: 5
    Last Post: 11-08-2005, 11:49 AM