inorder

Java Binary Tree. Priting InOrder traversal

I am having some problems printing an inOrder traversal of my binary tree. Even after inserting many items into the tree it's only printing 3 items. public class BinaryTree { private TreeNode root; private int size; public BinaryTree(){ this.size = 0; } public boolean insert(TreeNode node){ if( ro...

Reconstructing binary tree from inorder and preorder traversals.

I have written the following code for constructing a tree from its inorder and preorder traversals. It looks correct to me but the final tree it results in does not have the same inorder output as the one it was built from. Can anyone help me find the flaw in this function? public btree makeTree(int[] preorder, int[] inorder, int left,...

Can a non binary tree be tranversed in order?

Hi, We are dealing with a Most similar neigthbour algorithm here. Part of the algorithm involves searching in order over a tree. The thing is that until now, we cant make that tree to be binary. Is there an analog to in order traversal for non binary trees. Particularly, I think there is, just traversing the nodes from left to right (...