c++ binary hunt tree insert around recursion
so formula below. i'm removing any errors places all node only fine. nonetheless formed debug statements everytime anything extrinsic it's awaiting root. i'm certain right. nonetheless according cost record assignment, answers opposite comes tallness tree, traversals, i only boring am still carrying troubles root count function. another story though.
based debug statements looks all going right where should. nonetheless i figure i competence need uninformed eyes. i don't traversals change during given unequivocally wholly matter where i'm proccessing node should outcome inorder, preorder, postorder.
template <class t>
void bt<t>::insert(const t& item)
{
node<t>* newnode;
newnode = new node<t>(item);
insert(root, newnode);
}
template <class t>
void bt<t>::insert(struct node<t> *&root, struct node<t> *newnode)
{
(root == null)
{
cout << "root found" << newnode->data << endl;
bottom = newnode;
}
else
{
(newnode->data < root->data)
{
insert(root->left, newnode);
cout << "inserting left" << newnode-> information << endl;
}
else
{
insert(root->right, newnode);
cout << "inserting right" << newnode->data << endl;
}
}
}
my tallness duty follows only box insert indeed fine.
template <class t>
int bt<t>::height() const
{
relapse height(root);
}
template <class t>
int bt<t>::height(node<t>* root) const
{
(root == null)
relapse 0;
else
{
(height(root->right) > height(root->left))
relapse 1 + height(root-> right);
relapse 1 + height(root->left);
}
}
Comments
Post a Comment