Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

error in breadth first traversal

$
0
0
this is the BFT function m having problem in assigning dequeue node to curr
  queue<bnode<t>*>q;
  bnode<t>*curr=root;
  q.enqueue(curr);

  if(root==NULL)

  cout<<" tree empty "<<endl;

  else
  {
  while( curr )
  {
  curr=q.dequeue();
  q.display();

  if(curr->left!=NULL)
  //enqueue curr's left

  if(curr->right!=NULL)
 //enqueue its right


the compiler gives error " cannot convert bnode<bnode<int>*>* to bnode <int>*" in the dequeue function .
t queue<t>::dequeue()
 {
   if(front==NULL)
   return 0;

   else
   {
   bnode<t>*curr=front;
   front=front->next;
   curr->next=curr;
   return curr;   //error on this line
   }
 }


Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>