I am trying to make a crossword puzzle program utilizing BST's, i currently have the following words inserted into the tree:
word, will, wyr, wale, wilt, apple, abs, wack(inserted in that order)
but everytime i debug the program in visual studio, i get an error
Exception thrown at 0x008DE28C in AVLBSTcrosswordhunter.exe: 0xC0000005: Access violation writing location 0x0000001C.
However, when tracing the variables my traversed variable is never set to 1, so i do not exit this while loop, the error is happening inside, im just not sure where and why.
while (!traversed)
{
if (temp != NULL)
{
if (temp->word.substr(0, sub_num) == value.substr(0, sub_num))
{
count++;
}
s.push(temp);
temp = temp->left;
}
else
{
if (!s.empty())
{
temp = s.top();
s.pop();
temp = temp->right;
}
if (s.empty())
{
traversed = 1;
}
}
}
for clarification, the word i'm searching for is "w***"(the '*' being wildcards), so the if statement checks to see if the pointer temp has the substring w, and if sound it increases count so i can send a number back on how many match that wildcard search.
Also, temp is set to the root(word) before the while loop.
Thank you for any help that you can provide!
Seems that i created two traversed variables AND two stack variables in my hurrying to get this done, it seems to work now!
User contributions licensed under CC BY-SA 3.0