void Tree<Entry>::insert(Entry &x)
{
if(empty())
{
root=new Binary_node<Entry>(x);
count++;
return;
}
stack<int> s;
int tempcount=size();
while(tempcount>0)
{
if(tempcount%2==0)
s.push(2);
else
s.push(1);
tempcount=(tempcount-1)/2;
};
Binary_node<Entry> *current=root;
int a;
while(s.size()>1)
{
a=s.top();
s.pop();
if(a==1)
current=current->left;
else
current=current->right;
}
a=s.top();
if(a==1)
current->left=new Binary_node<Entry>(x);
else
current->right=new Binary_node<Entry>(x);
count++;
}
{
if(empty())
{
root=new Binary_node<Entry>(x);
count++;
return;
}
stack<int> s;
int tempcount=size();
while(tempcount>0)
{
if(tempcount%2==0)
s.push(2);
else
s.push(1);
tempcount=(tempcount-1)/2;
};
Binary_node<Entry> *current=root;
int a;
while(s.size()>1)
{
a=s.top();
s.pop();
if(a==1)
current=current->left;
else
current=current->right;
}
a=s.top();
if(a==1)
current->left=new Binary_node<Entry>(x);
else
current->right=new Binary_node<Entry>(x);
count++;
}