I created a method bool contains(string)
for a hash table of a linked list that checks if a value is in a hash. I use a helper function for recursion, but when the helper function returns false
, it bool contains(string)
still returns true. I passed it through the debugger, and I clearly see that it returns false, and I'm not sure why.
This searches for the current node:
"laccoliths"->"morbiferous"->"oculi"->"unscabbarded"
the meaning i'm looking for is this "typung"
.
Here is the code:
bool contains_h(string x, node * p)
{
if (p == NULL)
return false;
else if (x == p->data)
return true;
else
contains_h(x, p->next);
}
bool contains(string word) { return contains_h(word, head); }
source
share