[英]Binary Search Tree Access Violation on root node_ptr
I am getting "Unhandled exception at 0x00263ACB in Trees.exe: 0xC0000005: Access violation reading location 0x00000000." 我收到“ Trees.exe中0x00263ACB的未处理异常:0xC0000005:访问冲突读取位置0x00000000。” on the first if statement of remove_node function.
在remove_node函数的第一个if语句上。 Can anyone give me a suggestion, I am stumped.
任何人都可以给我一个建议,我很沮丧。
Thanks 谢谢
It looks like the error could be hidden here: In both cases you go to the left child and at some point approach a leaf (and try to delete its child which doesn't exist). 似乎该错误可能隐藏在这里:在两种情况下,您都转到左孩子,并在某个时候接近一片叶子(并尝试删除其不存在的孩子)。 Try to replace one of
remove_node(num, node_ptr->left);
尝试替换
remove_node(num, node_ptr->left);
by remove_node(num, node_ptr->right);
通过
remove_node(num, node_ptr->right);
Also it's a good idea to first check whether a node exists. 另外,最好先检查一个节点是否存在。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.