hello

I am creating binary search tree according to pseudo code posted in this forum but there is some problem can any one help me?

My code is

Code:

#include <conio.h>
#include <stdio.h>
#include <iostream.h>
struct list
{
int data;
list *left,*right;
};
list *root=NULL;
void preorder(struct list *root)
{
if(root!=NULL)
{
cout<<"\t"<<root->data;
preorder(root->left);
preorder(root->right);
}
}
void main()
{
struct list *current,*temp;
int n,num;
clrscr();
cout<<"\n How many nodes you want to create:- ";
cin>>n;
for(int i=0;i<n;i++)
{
cout<<"\n Enter data for node :- ";
cin>>num;
if(root==NULL)
{
temp=new list;
temp->data=num;
temp->left=NULL;
temp->right=NULL;
root=temp;
}
else
{
current=root;
while(current!=NULL)
{
if(num<current->data)
{
if(current->left==NULL)
{
current=current->left;
// continue;
}
else
{
current->left=new list;
current->left->data=num;
break;
}
}
else if(num > current->data)
{
if(current->right==NULL)
{
current=current->right;
// continue;
}
else
{
current->right=new list;
current->right->data=num;
break;
}
}
else
{
cout<<"\n Duplicate node";
break;
}
}
}
}
preorder(root);
getch();
}