Answer to Question #52584 in C++ for Masego

Question #52584
Write a definition of the function insertBTree to recursively inserts record into a b-tree
1
Expert's answer
2015-06-04T03:40:54-0400
template <typename T>
void BTTree<T> :: insertBTree(node<T>**tree,T item){
if(*tree == NULL){
*tree = new node<T>;
(*tree)->data = item;
(*tree)->left = NULL;
(*tree)->right = NULL;
}
else{
if( (*tree)->data > item)
insertBTree(&((*tree)->left),item);
else
insertBTree(&((*tree)->right),item);
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS