#include <bits/stdc++.h>
using
namespace
std;
struct
Node {
int
data;
struct
Node *left, *right;
};
struct
Node* newNode(
int
data)
{
struct
Node* node =
new
(
struct
Node);
node->data = data;
node->left = node->right = NULL;
return
(node);
}
int
height(
struct
Node* root)
{
if
(root == NULL)
return
0;
int
lheight = height(root->left);
int
rheight = height(root->right);
return
max(lheight, rheight) + 1;
}
void
LevelOrder(
struct
Node* root,
int
level,
int
& count)
{
if
(root == NULL)
return
;
if
(level == 1 && root->left && root->right)
count++;
else
if
(level > 1) {
LevelOrder(root->left, level - 1, count);
LevelOrder(root->right, level - 1, count);
}
}
int
CountFullNodes(
struct
Node* root,
int
L)
{
int
h = height(root);
int
count = 0;
LevelOrder(root, L, count);
return
count;
}
int
main()
{
struct
Node* root = newNode(7);
root->left = newNode(5);
root->right = newNode(6);
root->left->left = newNode(8);
root->left->right = newNode(1);
root->left->left->left = newNode(2);
root->left->left->right = newNode(11);
root->right->left = newNode(3);
root->right->right = newNode(9);
root->right->right->right = newNode(13);
root->right->right->left = newNode(10);
root->right->right->right->left = newNode(4);
root->right->right->right->right = newNode(12);
int
L = 3;
cout << CountFullNodes(root, L);
return
0;
}