Difficult recursion problem in C

  • Thread starter Thread starter dan.b
  • Start date Start date
  • Tags Tags
    Recursion
Click For 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.
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

Replies
5
Views
2K
Replies
7
Views
6K
  • · Replies 8 ·
Replies
8
Views
8K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 20 ·
Replies
20
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 31 ·
2
Replies
31
Views
3K
Replies
13
Views
4K