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

how to swap two numbers with out using temp variable

12 Answers   Global eProcure, TCS,


What is array in c++ pdf?

0 Answers  


Explain polymorphism?

0 Answers  


What is a .h file c++?

0 Answers  


give me an example for testing a program showing the test path .show how the test is important and complex.

0 Answers   TCS,


Can we overload operator in c++?

0 Answers  


Is c++ a pure oop language?

0 Answers  


What is the output of printf("%d")?

58 Answers   CTS, HCL, Infosys, TCS, Winit, Wipro,


Inline parameters : What does the compiler do with the parameters of inline function, that can be evaluated in runtime ?

0 Answers  


How can you specify a class in C++?

0 Answers  


What is the insertion operator and what does it do?

0 Answers  


Can you write a function similar to printf()?

0 Answers  


Categories