I am having problems with traversing a parce tree.
I need to do an in order traversal recursively.

Here's the class's private section...

template <class data>
class BinaryTree
{
	private:
		struct tNode
		{
			data info;
			tNode *left;
			tNode *right;
		};

		tNode *root;
	
	public:
};

I'll be calling inOrderTraversal() from main so I'll need the ability to pass it a tNode pointer, but the tNode struct has to be in the private section of the class. How can I do this? However, this is for a project and I don't want the answer. Just hints please! Thanks! (I have a little integrity)

P.S. if you need more info let me know

I am having problems with traversing a parce tree.
I need to do an in order traversal recursively.

Here's the class's private section...

template <class data>
class BinaryTree
{
	private:
		struct tNode
		{
			data info;
			tNode *left;
			tNode *right;
		};

		tNode *root;
	
	public:
};

I'll be calling inOrderTraversal() from main so I'll need the ability to pass it a tNode pointer, but the tNode struct has to be in the private section of the class. How can I do this? However, this is for a project and I don't want the answer. Just hints please! Thanks! (I have a little integrity)

P.S. if you need more info let me know

when u are writting a class try to make it very simple to the user, i.e. dont let the user give a node as an input because in that case the user needs to know what is a node and how is that represented.
the protorype for yuor traverse function should be like

void traverseInOrder();

to achieve this write the above as a public function and write a private function :

void traverseInorder(tNode* t);

call this function from the public function giving the root as input.

I thought about doing that last night, but was too frustrated with it to try it out. It's good to actually see it like you put it though. Thanks for the response.

This article has been dead for over six months. Start a new discussion instead.