I need to print the level order traversal of an AVL tree. I know how the idea works using a queue:
enqueue the node, and then enqueue the left and right nodes of it.
every node has a int data which needs to be printed
but then the thing is i don't know how to make queue of object type
void AvlTree<Comparable>::levelorder( )const
{
AvlNode<int> temp = root;
Queue<AvlNode> q ; //it would not allow me to do this
q.enqueue(root);
while (!q.isEmpty( ))
{
temp = q.dequeue();
cout<< (q.dequeue())->element;
if (temp->left !=NULL)
{ q.enqueue(temp->left);
}
if (temp->right !=NULL)
{ q.enqueue(temp->right);
}
}