help me please in bst insertion,i think something is wrong in insertion(insert function)
#include<bits/stdc++.h> using namespace std; struct node { int data; node *left; node *right; }; node * init(int data){ node * root=new node(); root->data=data; root->left=NULL; root->right=NULL; return root; } void insert(node * root,int x){ if(root==NULL) { root=init(x); // cout<<root->data<<endl; return ; } else if(root->data>x) insert(root->left,x); else if(root->data<x) insert(root->right,x); } void printe(node*root){ if(root==NULL)return; cout<<root->data; printe(root->left); printe(root->right); } int main(){ int ar[]={5,3,6,4,23,6}; node * root=init(ar[0]); for(int i=1;i<6;i++){ insert(root,ar[i]); } cout<<"print"<<" "; printe(root); //cout<<"root->l->data"<<root->left->data<<endl; }