Difficult recursion problem in C

  • Thread starter Thread starter dan.b
  • Start date Start date
  • Tags Tags
    Recursion
Click For Summary

Discussion Overview

The discussion revolves around a recursive programming problem in C, specifically focused on generating all possible subsets of a given size from a specified word, without using loops, pointers, or static variables. The participants explore various aspects of recursion and subset generation techniques.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant expresses frustration with the problem and seeks assistance in writing a recursive function to generate subsets.
  • Another participant points out that the requirement of no pointers contradicts the function's need for pointer arguments, suggesting a depth-first recursion approach for the solution.
  • A different participant clarifies that using pointer types is not allowed, but passing addresses in the array is acceptable, and requests an example of the first recursion technique.
  • One participant describes a method for generating subsets of a specific size, outlining a recursive strategy that involves adding elements to subsets and considering base cases.
  • Another participant comments that the previous response provided too much assistance, implying a preference for less direct help.
  • A later reply indicates a willingness to remove part of the previous explanation, suggesting a desire to maintain a certain level of challenge in the discussion.

Areas of Agreement / Disagreement

Participants exhibit disagreement regarding the interpretation of the problem constraints, particularly around the use of pointers. The discussion remains unresolved as participants explore different approaches and clarify their understanding of recursion.

Contextual Notes

Limitations include the unclear definition of allowed pointer usage and the need for base cases in the recursive function, which have not been fully addressed.

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.
 

Similar threads

Replies
5
Views
2K
Replies
7
Views
6K
  • · Replies 8 ·
Replies
8
Views
9K
  • · 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 31 ·
2
Replies
31
Views
3K
  • · Replies 12 ·
Replies
12
Views
3K
Replies
13
Views
4K