#Binary tree function

6 messages · Page 1 of 1 (latest)

plain parcel
#

int main()
{
    bool ht_inc;
    int data, num;
    struct node *root = NULL;
    struct node *largest;
    while (1)
    {
        printf("1.Insert\n");
        printf("2.Display\n");
        printf("3.Quit\n");
        printf("Enter your option : ");
        scanf("%d", &num);
        switch (num)
        {
        case 1:
            printf("Enter the value to be inserted : ");
            scanf("%d", &data);
            if (search(root, data) == NULL)
                root = insert(data, root, &ht_inc);
            else
                printf("Duplicate value ignored\n");
            break;
        case 2:
            if (root == NULL)
            {
                printf("Tree is empty\n");
                continue;
            }
            printf("Tree is :\n");
            display(root, 1);
            printf("\n\n");
            printf("Inorder Traversal is : ");
            inorder(root);
            printf("\n");
            break;
        case 3:
            root = findLargestElement(root);
            printf("%d", root->data);
        case 4:
            exit(1);
        default:
            printf("Wrong option\n");
        }
    }
}

struct node *findLargestElement(struct node *tree)
{
    if ((tree == NULL) || (tree->right == NULL))
        return tree;
    else
        return findLargestElement(tree->right);
}```
Can someone help me understand why it's returning "implicit declaration" ?
tardy knollBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

plain parcel
#

Oh uh it seems they forgot to include the .h file..

#

!solved

#

!solved