if there is binary tree which one is the easiest way to
delete all child node?

Answer Posted / q

class BinaryTreeNode
{
BinaryTreeNode *left,*right;
public:

//....

//....
~BinaryTreeNode()
{
if(left) delete left;
if(right) delete right;
}

};

delete root, all child nodes will be deleted recusively...

Is This Answer Correct ?    11 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why do we need pointers?

665


What is the output of the following program? Why?

720


Give example of a pure virtual function in c++?

689


Can a list of string be stored within a two dimensional array?

666


Is c++ a float?

701






Who discovered c++?

656


What is the difference between #import and #include?

671


Where the memory to the static variables is allocated?

646


What is friend class in c++ with example?

592


Why c++ does not have finally?

715


Why do we use classes in programming?

657


What is static function? Explain with an example

675


Why would you use pointers in c++?

716


What new()is different from malloc()?

672


What happens when the extern "c" char func (char*,waste) executes?

724