Bfs traversal using queue

can you explain why we make a queue of node* to store the element? if we take int type queue what’s the problem with that

If u take it of int type then how will u add child of nodes to the queue inside loop,how will u keep track of them

but prateek bhaiya
write like this in initial->>

queue<node*> q;

q.push(root->data);

bcz root->data is int

He must have written it by mistake, see the complete video ,he might have corrected it in last.

1 Like

okkk i seen later that…:grin:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.