Iterative PostOrder traversal deletes the Whole tree, in Scala we have :
override def clone():BinarySearchTree=
{
return new BinarySearchTree(root.clone())
}
Then we copy the whole tree by using :
def postorder(tnode:TreeNode)
{
var tcnode=tnode.clone
}
now tcnode have the copy of the whole tree. But I want to do the same in python I tried using :
import copy
def postOrder(self, tnode):
tcnode = copy.copy(tnode)
but it's not working.