class Tree
{
private:
Tree* root;
public:
int value;
Tree* left;
Tree* right;
void insert(Tree* &root, int newValue);
void printInOrder(Tree* node);
void TreeSort (int list[], int N);
};
void insert(Tree* &root, int newValue)
{
if(root== NULL)
{
root = new Tree;
root-> value = newValue;
root -> left = NULL;
root -> right = NULL;
return;
}
else if(newValue < root->value)
{
insert(root->left,newValue);
}
else
insert(root->right,newValue);
}
void printInOrder(Tree* node)
{
if(node = NULL)
return;
else
{
printInOrder(node->left);
cout<value;
printInOrder(node->right);
}
}
void TreeSort (int list[], int N)
{
Tree* root;
root= NULL;
for (int i=0; i{
insert(root, list[i]);
}
printInOrder(root);
}
int main(int argc, char** argv[])
{
Tree bst;
int numArray;
cout<<"Enter num to be inserted in array\n";
cin>>numArray;
int* list = new int[numArray];
cout<<"Enter numbers:\n";
for(int i=0; i>numArray; i++)
{
cin>>list[i];
}
bst.TreeSort(list, numArray);
system("pause");
return 0;
}