Question: Help in my C++ program for removal of nodes from binary tree. Can I use the code: void deallocateTree(course* p) { if (p==0) return; delete

Help in my C++ program for removal of nodes from binary tree. Can I use the code:

void deallocateTree(course* p)

{

if (p==0) return;

delete p;

deallocateTree(p->yes);

deallocateTree(p->no);

}

or:

void deallocateTree(course* p) { if (!p) return; deallocateTree(p->yes); deallocateTree(p->no); delete p; }

Which one is better or they are the same? Thanks

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!