【发布时间】:2017-02-15 05:05:25
【问题描述】:
/*
Here is the piece of code causing segmentation fault
*/
int search_for_data(T_NODE head, int data){
while(head){
if( head->data > data)
head = head->left;
if( head->data < data)
head = head->right;
else
return head->key;
}
return -999999;// in case the node is not found
}
代码似乎对少数几个值抛出了分段错误,但对其他值却很好。我尝试搜索 22 并且出现分段错误。
【问题讨论】:
标签: segmentation-fault binary-search-tree