PDA

View Full Version : difficult recursion problem in C


dan.b
Jun19-09, 09:19 AM
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?

D H
Jun19-09, 09:47 AM
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.

dan.b
Jun19-09, 09:54 AM
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?

mXSCNT
Jun19-09, 02:50 PM
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.

D H
Jun19-09, 03:41 PM
That's a bit too much help, mXSCNT.

mXSCNT
Jun19-09, 04:30 PM
Alright, I'll delete the second part.