高级数据结构(第三节课)__2018.7.15

代码:

void NiceInOrder(BtNode *ptr)
{
	if (ptr == NULL) return;
	stack<BtNode*> st;
	while (ptr != NULL || !st.empty())
	{
		while (ptr != NULL)
		{
			st.push(ptr);
			ptr = ptr->leftchild;
		}
		ptr = st.top();st.pop();
		if (ptr->rightchild == NULL || ptr->rightchild == tag)
		{
			cout << ptr->data << " ";
			tag = ptr;
                        ptr=NULL;
		}
		else
		{
			st.push(ptr);
			ptr = ptr->rightchild;
		}
	}
}

深度遍历:前序、中序、后序遍历。

广度遍历:

没有死递归这一说法。总有一个退出递归的条件。

BST树。

二叉树的遍历规则。

要有解决问题的能力。

判断二叉树是不是一个完全二叉树,是不是一个满二叉树。

是否是一个BST树,排序二叉树。

是否是一个平衡二叉树。

247早上高级数据结构

猜你喜欢

转载自blog.csdn.net/weixin_40316053/article/details/81050392