Hi Folks,
I've had problems with recursive functions before, but this one's making me
crazy.
I have a trie (tree) data structure and I'm trying to find a sequence of ints
in the trie.
- (HSMM_TrieNode*) getTrieNodeFromContextSequence:(NSMutableArray *)aSequence
withNode:(HSMM_TrieNode*) aNode
You never seem to be capturing the result of the recursive calls for return
to the caller.
You final if block should look like this:
if(([endNode depth] ([self contextDepth] - 1)) ([mutableSeq
count] 1) (found == YES))
{
[mutableSeq removeObjectAtIndex:0];
Can anyone see why the caller is getting the first match, rather than the
last?
Immense thanks to anyone who can see what's up.
I think in the line when going down the recursion, you have to assign the
result to endNode:
endNode = [self getTrieNodeFromContextSequence:mutableSeq
LOL!!!
Yipes, how embarrassed am I
So clever, yet so stupid...
thanks a million.
J.
On 2010-03-25, at 9:58 AM, Howard Siegel wrote:
You never seem to be capturing the result of the recursive calls for return
to the caller.
You final if block should look like this: