Answer to Question #210650 in C++ for Usman Ali

Question #210650

Write code to in the form of function to delete a sub-tree of general tree whose parent node is p


1
Expert's answer
2021-06-25T16:10:13-0400
//Delete a sub tree recursively
void delete_node(Node *P){
  // Do not do anything if the root is null 
 if (root == NULL) { return; }

  // Deleting a subtrees
  delete_node(P->left_node);
  delete_node(P->right_node);

  // Deletiing the current node
  free(P);
  P = NULL;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS