假设二叉树采用二叉链表存储结构,设计一个算法求其指定的某一层k(k>1)的叶子结点个数,要求: (1)给出算法的基本设计思想。
(2)写出二叉树采用的存储结构代码。 (3)根据设计思想,采用C或C++语言描述算法,关键之处给出注释。
// 二叉树数据结构.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include <iostream>
using namespace std;
#define eletype int
typedef struct BiNode {
eletype data;
struct BiNode* lchild, * rchild;
}BiNode, * BiTree;
static int num = 1;
static int ans = 0;
void CreateBiTree(BiTree T) {
T->data = 1;
BiTree a = (BiTree)malloc(sizeof(BiNode));
a->data