-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