二叉树(二)
//if the right sibling is empty, then, the note item replace its parent.
rc = lc;
else
combine(lc,rc->L);//always "Gua" the note item(lc) to the left(est) leaf of his right sibling(rc)
}
};
int _tmain(int argc, _TCHAR* argv[])
{
//input and construct the BST
bst b;
cout << "input some integers:";
for(;;){
int n;
cin >> n;
b.insert(n);
break;
} www.2cto.com
//find the old value node, then delete it and replace with the node with new value
for(;;){
cout << "input data pair:";
int od,nd;
cin >> od >> nd;
if(od == -1 && nd == -1)
break;
b.update(od,nd);
}
b.travel();
return 0;
}