Question: when I send a query to my bst to return a t/f value upon whether or not the element is found, it works correctly when true, but causes a delayed crash when the element isn't in the bst.

I can't figure this out for the life of me.

.cpp

```
bool BinarySearchTree::find(std::string title){

    if (root == NULL)
        return 0;

    return findHelper(root,title);
}

bool BinarySearchTree::findHelper(Node* current, std::string title){

    if (current->title.compare(title) == 0)
        return 1;

    if (current->title.compare(title) < 0)
        findHelper(current->left, title);
    else
        findHelper(current->right, title);

    return 0;
}

```

main

```
if (select == 4) {

            bool x;

            string s;

            cout << "Enter Title: " << endl;

            cin.ignore();
            getline(cin, s);

            x = t.find(s);
            if (x)
                cout << "found" << endl;
            else
                cout << "unfound" << endl;

            printMenu();

            cout << "Enter Choice: ";

            cin >> select;

}

```

Thank you.

Answer: 
When you do recursion, you should return whatever the recursive call is returning, not 0. You only return 0 if you reach the end of the tree.

```
bool BinarySearchTree::findHelper(Node* current, std::string title)
{
    if (current == nullptr)
        return 0;

    if (current->title.compare(title) == 0)
        return 1;

    if (current->title.compare(title) < 0)
        return findHelper(current->left, title);
    else
        return findHelper(current->right, title);
}

```
You don't have any way to stop the recursion in `findHelper`, so you eventually dereference current when it is a nullptr .