-2
void BinTree::arrayToBSTreeHelper(NodeData* toRead[], Node* current, int low, int high) // ******
{
if (low >= high)
{
return;
}
int midPoint = (low + high)/2;
cout << "low, midPoint, and high at entry to helper: " << low << " " << midPoint << " " << high << endl; // ****** prints 0, 6 and 13
insert(toRead[midPoint]); // ****** insert takes a NodeData*
arrayToBSTreeHelper(toRead, current->left, low, midPoint); // ERROR
arrayToBSTreeHelper(toRead, current->right, midPoint + 1, high);
}
low,midPoint和high的打印输出发生一次,然后在第一次递归调用中给出“不良访问”消息。 “插入”已经过测试,似乎正常工作。这个递归例程为什么给出EXC_BAD_ACCESS(code = 1,address = 0x8)?
递归地传递NodeData *数组“toRead”似乎有问题,但我无法弄清楚它是什么。
环境是Xcode 7.1。
请发布[最小,完整和可验证示例](http://stackoverflow.com/help/mcve)。 –
'current'为空。 – molbdnilo