Binary search Tree

hi guys,
can you help me with my code I have a problem with my function it is not print the number in pre-order.
please i need a quick help because i have one hour to send the assignment
my code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
void preOrder(BSTNode* root)
{
	queue<BSTNode*> Pre;
	Pre.push(root);
	while(!Pre.empty())
	{
		BSTNode *root = Pre.front();
		Pre.pop();
		if(root!= NULL)
		{
			
			Pre.push(root->left);
			Pre.push(root->right);
			cout << root->value << " ";
		}
		
	}
	
}

it spouse to print the number like this
54 22 17 41 36 30 26 27 45 74 76 82
but it print
54 22 47 17 41 76 36 45 82 30 26 27
Topic archived. No new replies allowed.