2.19总结
最短路径:一小时
拓扑排序:两小时
二叉树层次遍历(博客):一小时
mooc网课观看:两小时
Java学习:两小时(b站看视频)
void LevelOrderTraversal (struct tree *root)
{
struct tree* temp;
Push(root);
while (!empty())
{
temp = Pop();
printf("%c", temp->data);
if (temp->lchild)
Push(temp->lchild);
if (temp->rchild)
Push(temp->rchild);
}
}
层次遍历二叉树需要用到队列
struct queue
{
struct tree *numQ[1000];
int front;
int rear;
} Queue,Q;
void initilize()
{
Q.front=0;
Q.rear=0;
}
void Push(struct tree *root)
{
Q.numQ[++Q.rear]=root;
}
struct tree* Pop()
{
return Q.numQ[++Q.front];
}
int empty()
{
return Q.rear == Q.front;
}