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

What are the advantages of inheritance in c++?

654


Can a built-in function be recursive?

580


Explain the term memory alignment?

676


What are the data types in c++?

513


What are advantages of c++?

560






What is purpose of abstract class?

583


How can you quickly find the number of elements stored in a a) static array b) dynamic array ? Why is it difficult to store linked list in an array?how can you find the nodes with repetetive data in a linked list?

615


What do c++ programmers do?

551


Describe the role of the c++ in the tradeoff of safety vs. Usability?

711


Can union be self referenced?

574


What are the advantages of using const reference arguments in a function?

613


What are pointers used for c++?

569


Is c++ pass by reference or value?

567


Explain stack unwinding.

631


To what does “event-driven” refer?

607