void widthFirst(Node *root)
{queue<Node*> nodeQueue;
nodeQueue.push(root);
while(!nodeQueue.empty())
{
Node* temp = nodeQueue.front();
cout << temp->data << ' ';
nodeQueue.pop();
if (temp->left);
nodeQueue.push(node->left);
if (temp->right)
nodeQueue.push(node->right);
}
}
//深度优先遍历的输出为先序输出
void depthFirst(Node* root){
stack<Node*> nodeStack;
nodeStack.push(root);
while(!nodeStack.empty())
{
Node* temp = nodeStack.top();
cout << temp->data << ' ';
nodeStack.pop();
if(temp->left)
nodeStack.push(node->left);
if (temp->right)
nodeStack.push(node->right);
}
}