Sandeep N L
BAN USERI agree with you. And also i suppose the overhead of balancing the tree with outplay the overhead to remove items from List.
- Sandeep N L February 02, 2012public class ReverseBinTree {
/**
* @param args
* @author sandeep
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
BinaryTree seven = new BinaryTree(7, null, null);
BinaryTree six = new BinaryTree(6, null, null);
BinaryTree three = new BinaryTree(3, six, seven);
BinaryTree five = new BinaryTree(5, null, null);
BinaryTree four = new BinaryTree(4, null, null);
BinaryTree two = new BinaryTree(2, four, five);
BinaryTree root = new BinaryTree(1, two, three);
revBinTree(root);
System.out.println("The reversed tree is " + root.toString());
}
private static void revBinTree(BinaryTree root) {
// TODO Auto-generated method stub
if(root != null){
BinaryTree temp = root.left;
root.left = root.right;
root.right = temp;
revBinTree(root.left);
revBinTree(root.right);
}
}
}
I agree with you. And also i suppose the overhead of balancing the tree with outplay the overhead to remove items from List.
- Sandeep N L February 02, 2012