OD order 状态一问# PDA - 掌中宝
t*n
1 楼
Given a binary tree, how would you write program for getting mirror image of
tree in O(n) time? Is it possible ? Assume you have no constraints on space.
我只能想到递归:
Mirror(Node* p){
Mirror(p->left);
Mirror(p->right);
ExchangeLeftRight(p);
}
这个复杂度应该怎么算?
tree in O(n) time? Is it possible ? Assume you have no constraints on space.
我只能想到递归:
Mirror(Node* p){
Mirror(p->left);
Mirror(p->right);
ExchangeLeftRight(p);
}
这个复杂度应该怎么算?