class TreeNode { TreeNode left; TreeNode right; int val; TreeNode(int val) { this.val=val; } } void preorder(TreeNode t) { if(t!=null) { visit(t); preorder(t.left); preorder(t.right); } } void inorder(TreeNode t) { if(t!=null) { inorder(t.left); visit(t); inorder(t.right); } } void postorder(TreeNode t) { if(t!=null) { inorder(t.left); inorder(t.right); visit(t); } }