#include<iostream> using namespace std; struct Node{ int data; Node *left; Node *right; Node(int data, Node *left, Node *right): data(data), left(left), right(right){} }; void Insert(Node *root, int data){ if(data >= root->data){ if(root->right == NULL){ root->right = new Node(data, NULL, NULL); } else Insert(root->right, data); } else{ if(root->left == NULL){ root->left = new Node(data, NULL, NULL); } else Insert(root->left, data); } } void print(Node *root){ if(root != NULL) cout<<root->data<<endl; if(root->left != NULL) print(root->left); if(root->right != NULL) print(root->right); } int main(){ Node *root = new Node(5, NULL, NULL); Insert(root, 8); Insert(root, 6); Insert(root, 9); Insert(root, 7); Insert(root, 10); Insert(root, 3); Insert(root, 2); Insert(root, 4); Insert(root, 1); print(root); return 0; }