Question: In addition to the value, each node stores in a data member named count the number of nodes in the tree rooted at that node

 In addition to the value, each node stores in a data

In addition to the value, each node stores in a data member named count the number of nodes in the tree rooted at that node (see the illustration for an example). 10 count -9 5 Count = 6 15 count = 2 3 count 2 7 count = 3 20 count = 1 2. count = 1 6 count - 1 9 count 1 What modifications need to be made to the following code for the insert function in order for the count variable to be updated correctly? Provide only the line number(s) and the modified code at these lines only (do not re-write the whole function). template 2 void BSTCT>:: insert(T& val) { 3 TNodecT>* newNode - new TNode (val, nullptr, nullptr); 4 5 if (isEmpty() { 6 root = newNode; 7 return; 8 } 9 10 TNodecT> p = nullptry 11 TNode Croot; 12 13 while ( I nullpt) { 14 pc; 15 16 if (val > C->data) 17 CC->right; 18 else 19 C - C->left; 20 } 21 22 if (val > p->data ) 23 p->right - newNode; 24 else 25 p->left = newNode

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!