数据结构算法—非递归算法求二叉树的叶子结点(C语言)
学过数据结构中 队列和栈的同学,应该都明白: 使用队列和栈,可以将递归算法转换成非递归算法
在递归算法中,需要重复调用函数时,在非递归算法中,就需要入栈,进入下一层。
在递归算法中,返回调用函数的结果时,在非递归算法中,就需要出栈,返回到上一层
#include<stdio.h>
#include<malloc.h>
struct node{
char info;
struct node *llink,*rlink;
};
typedef struct node NODE;
NODE *creat(){
char x;
NODE *p;
scanf("%c",&x);
printf("%c",x);
if</

最低0.47元/天 解锁文章
1526





