How to deep copy a Binary Tree?
问题 I would like using my own Node class to implement tree structure in Java. But I'm confused how to do a deep copy to copy a tree. My Node class would be like this: public class Node{ private String value; private Node leftChild; private Node rightChild; .... I'm new to recursion, so is there any code I can study? Thank you! 回答1: try class Node { private String value; private Node left; private Node right; public Node(String value, Node left, Node right) { this.value = value; ... } Node copy()