Introduction - If you have any usage issues, please Google them yourself
#include <stdio.h>
#include <string.h>
#include <windows.h>
struct BTree {
int data
struct BTree* left
struct BTree* right
} //end struct BTree
BTree* CreateLeaf(int number)
{
BTree* l = new BTree
l->data = number
l->left = 0
l->right = 0
return l
}//end CreateLeaf
void append(BTree** root, int number)
{
if (!root) return
BTree* t =*root
if (!t) {
*root = CreateLeaf(number)
return
}//end if
while(t) {
if(number == t->data ) return //ignore duplicated elements.
if(number < t->data ) {
if(!t->left ) {
t->left = CreateLeaf(number)
return
}//end if
t = t->left
}else{
if(!t->right ) {
t->right = CreateLeaf(number)
return
}//end if
t = t->right
}//end if
}//end while
}//end append
void PrintLeaf(const BTree* root)
{
if (!root) return
if (root->left ) PrintLeaf(root->left )
printf(" d\t", root->data)
if (root->right ) PrintLeaf(root->right )