Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write C++ code for the following questions: a. Implement the member function isE

ID: 3771181 • Letter: W

Question

Write C++ code for the following questions:
a. Implement the member function isEmpty(). The function returns true is the binary tree is empty, otherwise returns false.

b. Implement the member function inorderTraversal(). The function prints out all the data values of a binary tree by in-order traversal.

c. Implement the destructor ~BTree(). The function deletes all the nodes in a binary tree. The binary tree might be empty(.Hint: It is easier to write the function in a recursive manner. You may declare additional functions if you wish.)

this is a c++ plus.

Explanation / Answer

a)

b)

void BTree::inorder(){

inorder(root);

}

void BTree::inorder(node *ptr)
{
if (root == NULL)
{
cout<<"Tree is empty"<<endl;
return;
}
if (ptr != NULL)
{
inorder(ptr->left);
cout<<ptr->info<<" ";
inorder(ptr->right);
}
}

c)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote