最新回答 / o0wzn0o
好好看Tree.h,里面寫了 private: Node *m_pRoot;? ?m_pRoot是Node類,它所指的成員函數當然是Node類下的SearchNode。建議你好好動手寫一遍代碼,光看是不解決問題的
2018-11-17
這樣寫可以嗎哈哈?
Node * Node::SearchNode(int nodeindex)
{
Node *tempNode = NULL;
if(this->index == nodeindex) return this;
if(this->pLeftChild != NULL)
{
tempNode = this->pLeftChild->SearchNode(nodeindex);
if(tempNode != NULL) return tempNode;
}
……后面類似
Node * Node::SearchNode(int nodeindex)
{
Node *tempNode = NULL;
if(this->index == nodeindex) return this;
if(this->pLeftChild != NULL)
{
tempNode = this->pLeftChild->SearchNode(nodeindex);
if(tempNode != NULL) return tempNode;
}
……后面類似
2018-10-05
之前看了嚴蔚敏的數據結構,斷斷續續看了兩遍感覺沒弄懂,現在看這個視頻感覺效果很不錯。謝謝老師了~
另外,個人覺得老師把樹的非遞歸遍歷再實現一下就很好了,這個是面試的一個熱門。哈哈哈哈
另外,個人覺得老師把樹的非遞歸遍歷再實現一下就很好了,這個是面試的一個熱門。哈哈哈哈
2018-09-07
最贊回答 / Cocoabeans
我的理解是,如果pNode==NULL,就相當于pNode這個結點不存在,就更不存在pNode -> data = temp -> data這一步了。pNode就是把要刪除的那個結點的內容保存下來的結點
2018-08-03