I can't find the bug in my code!

Problem description:
Can you help me find the bug im my code? I don’t know what “core dumped” means !!

Expected behavior:

Actual behavior:

Steps to reproduce:

Bug appears at this link:

Browser/OS/Device:

Welcome to the forums! Can you please send a link to the Repl?

3 Likes

I found the repl by checking your replit profile https://replit.com/@mohammedabd10/hw1?v=1
The main cause for segmentation faults is dereferencing null or invalid pointers.
The easiest way to fix them is to use replits debugger.

The debugger stops here

root->height = 1 + _max((root->child[LEFT]->height), (root->child[RIGHT]->height));

When root has no children root->child[LEFT] is 0
So you need to add checks that there actually are children, or ensure that there always will be.

2 Likes