Hello Guys,

I am traversing a binary tree in java. I can print the whole tree whitout any problem.

I do it this wat

private void printNode(String path)
	{
		if ((left==null) && (right==null)){
			System.out.println("Val \"" + MyChar + "\" binary value  " + path);

		}
		if (left != null)
			left.printNode(path + '0');
		if (right != null)
			right.printNode(path + '1');
	}

	public static void printTree(Nodes tree)
	{
		tree.printNode("");
	}

It is working well, but i cannot find the method to access to a specific value for example
0111

Could you give me a hand it would be really appreciated

We can't "give" you the code. In a BST, numbers greater than the value of the current Node are in its right child, and less than are in its left child. Therefore, if you're looking for a certain value/Node, just search logically until you hit that Node. Then return it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.