3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by programmersbook
0

.hpp missing, to test it local, can you provide them?

btw, just a hint:

void BinarySTree::copyTree(TreeNode* treePtr, TreeNode* newTreePtr){
    if (treePtr!=NULL){
        newTreePtr == new TreeNode(treePtr->item, NULL, NULL);


        // newTreePtr == new(std::nothrow) TreeNode(treePtr->item, NULL, NULL);
        // newTreePtr -> no memory -> newTreePtr will be NULL
        
        // this will NOT happen!
        // new will throw bad_alloc
        if (newTreePtr ==NULL)
            cout<<"Cannot allocatememory";
        copyTree(treePtr->leftChildPointer, newTreePtr->leftChildPointer);
        copyTree(treePtr->rightChildPointer, newTreePtr->rightChildPointer);
    }else{
        newTreePtr = NULL; //copyEmptyTree
    }
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.