#include using namespace std; struct node { int val; node *L; node *R; node *O; node() { node *O = NULL; }; }; void insertbst(node *&root, int x) { if (root == NULL) { root = new node; root->val = x; root->L = root->R = NULL; cout << "nic tu nie ma" << endl; } else { if (x < root->val) { insertbst(root->L, x); root->L->O = root; cout << "idziemy głębiej w lewo..." << endl; } else { insertbst(root->P, x); root->P->O = root; cout << "idziemy głębiej w prawo..." << endl; } } } void inorder(node *&root) { if (root != NULL) { inorder(root->L); cout << root->val << " "; inorder(root->P); } } int main() { node *root = NULL; insertbst(root, 4); insertbst(root, 2); insertbst(root, 11); insertbst(root, 1); insertbst(root, 7); insertbst(root, 25); inorder(root); system("PAUSE"); return 0; }