6-11先序输出叶结点

题目描述

按照先序遍历的顺序输出给定二叉树的叶结点。

题目地址为:https://pintia.cn/problem-sets/15/problems/925

BinTree结构定义

1
2
3
4
5
6
7
typedef struct TNode *Position;
typedef Position BinTree;
struct TNode{
ElementType Data;
BinTree Left;
BinTree Right;
};

打印结点

思考

不就是先序遍历,然后只输出左右子树都为NULL的结点吗?