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



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

Answer / 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

More C++ General Interview Questions

What is the benefit of c++?

0 Answers  


What are the different types of polymorphism?

3 Answers  


How to write a program such that it will delete itself after exectution?

3 Answers  


What are static variables?

0 Answers  


What is a node class in c++?

0 Answers  






In int main(int argc, char *argv[]) what is argv[0] a) The first argument passed into the program b) The program name c) You can't define main like that

0 Answers  


Why isn't sizeof for a struct equal to the sum of sizeof of each member?

0 Answers  


Can I make ios apps with c++?

0 Answers  


What is a constructor and how is it called?

0 Answers  


class X { private: int a; protected: X(){cout<<"X constructor was called"<<endl;} ~X(){cout<<"X destructor was called"<<endl} }; Referring to the code above, which one of the following statements regarding "X" is TRUE? a) X is an abstract class. b) Only subclasses of X may create X objects. c) Instances of X cannot be created. d) X objects can only be created using the default copy constructor. e) Only friends can create instances of X objects.

2 Answers   Quark,


What will strcmp("Astring", "Astring"); return a) A positive value b) A negative value c) Zero

0 Answers  


Can you please explain the difference between static and dynamic binding of functions?

0 Answers  


Categories