Difficult recursion problem in C

  • Thread starter Thread starter dan.b
  • Start date Start date
  • Tags Tags
    Recursion
AI Thread Summary
The discussion revolves around creating a recursive function to generate all possible subsets of a specified size from a given word, with specific constraints: no loops, no pointers, and no static variables. The emphasis is on using depth-first recursion to achieve the desired output format, where subsets are separated by commas. Participants highlight the importance of understanding the first recursion technique, suggesting that subsets of size m can be formed by adding the first element to subsets of size m-1 from the remaining elements. Base cases are also mentioned, specifically when the subset size is zero or when there are no elements left to consider. The conversation indicates a need for clarity on recursion principles and examples to illustrate the concept effectively.
dan.b
Messages
2
Reaction score
0
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:
Technology news on Phys.org
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.
 
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?
 
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:
That's a bit too much help, mXSCNT.
 
Alright, I'll delete the second part.
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
Thread 'Project Documentation'
Trying to package up a small bank account manager project that I have been tempering on for a while. One that is certainly worth something to me. Although I have created methods to whip up quick documents with all fields and properties. I would like something better to reference in order to express the mechanical functions. It is unclear to me about any standardized format for code documentation that exists. I have tried object orientated diagrams with shapes to try and express the...
Back
Top