(7分)已知二又树结点的抽象类定义如下:
//Binary tree node abstract class
template
public:
virtual ~BinNode()(}//Base destructor
//Return the node’s value
virtual E& element() = 0;
// Set the node’s value
virtual void setElement(const E&)= 0;
//Return the node’s left child
virtual BinNode* left() const = 0;
// Set the node's left child
virtual void setLeft(BinNode*)=0;
//Return the node’s right child
virtual BinNode* right() const=0
//Set the node's right child
virtual void setRight (BinNode*)=0;
virtual bool isLeaf()=0;};
试问以下函数具有什么功能?
void BinaryTreeOperation(BinNode *root){
Stack
BinNode *p=root;
while(p!=NULL |!s.length()!=0){
while(p!-NULL){
s. push(p);
p=p->left ():
if(!StackEmpty(s)){
p=s.pop();
visite(p->element());
p-p->right();
}//endif
}//endwhile
}
查看答案和解析【26考研辅导课程推荐】:26考研集训课程,VIP领学计划,26考研VIP全科定制套餐(公共课VIP+专业课1对1) , 这些课程中都会配有内部讲义以及辅导书和资料,同时会有教研教辅双师模式对大家进行教学以及督学,并配有24小时答疑和模拟测试等,可直接咨询在线客服老师领取大额优惠券。
启航教育热门私房课
MORE小班面授 名额有限 抢先体验
编辑推荐
最新内容
姓名
手机号