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.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...
Back
Top