+ 4
Would you help to fix the problem in lines from 31 to 39?
In the header file there are methods etc. for Binary Search Tree as map in c language of programming. This is the header file : https://code.sololearn.com/cbBRQc5kIklU/#c And this is the map.c file: https://code.sololearn.com/chRjOZNNGOLX/#c which I have problems in lines from 31 to 39? Would you please help to fix them?
6 Réponses
+ 1
Hello. I think, its here:
“if(mp!=NULL){...}
else if(mp->value>val)....”
if MP not NULL, you fill it, ok; but this IF has ELSE-branch, and you happen there when MP is NULL, and at this time try to get access by empty pointer -> error
+ 4
Dmitrii ok, seems understandable , would you tell the syntaxis of creating a new node?
+ 3
Dmitrii so what shall we do?)
+ 3
Dmitrii how do we make sure that key-value pair is created successfully ?
+ 1
so, is no need to check equality mp and null, but check equality mp->root and null is a good idea in order to understand, does map empty. In another case, you should create new tree node and connect it to suitable node to left or right
+ 1
you have it in function which creates new map, when you create root, just realize that 3 lines as function and use it in define function