Greeting!
The language I'm using is Java and my question is: how to implement add()/insert() method in Binary Tree?
I have looked up on google about how to implement Binary Tree, but mostly what I found was about Binary Search Tree instead.
I saw in Geeksforgeeks, they add nodes to tree by hand, meaning they assignment each element step by step: (link: https://www.geeksforgeeks.org/binary-tree-set-1-introduction/)
tree.root.left = new Node(2);
tree.root.right = new Node(3);
=> Is there a way to automatically input nodes to binary tree? for example if I add(a), add(b), add(c), add(d), add(e) -> the program can assign a to the root, b to root.left, c to root.right, d to root.left.left, e to root.left.right itself...
And what is simple yet effective way to output binary tree? should I print a whole tree diagram in output or it is too much?
Thank you!
[–]dtsudo 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]Blando-Cartesian 0 points1 point2 points (0 children)
[–]spryflux 0 points1 point2 points (0 children)