i know how to insert, print binary tree but how to print it like this? note that leafs and nodes will change and dont have to be same as this.
this is what i have, but this prints 6,1,0,7,8. i want to add space and slashs.
Code:
ex: 6 / \ 1 7 / / \ 0 5 8
this is what i have, but this prints 6,1,0,7,8. i want to add space and slashs.
Code:
public void PreOrderTraversal(node root_node) { if (root_node == null) { System.out.println("Binary Tree is empty!"); } else { System.out.println(root_node.name + " " + root_node.age); PreOrderTraversal(root_node.left_child); PreOrderTraversal(root_node.right_child); } }
Comment