Hi there
The doubt i am asking for is for this question ->https://algorithms.tutorialhorizon.com/in-a-binary-tree-create-linked-lists-of-all-the-nodes-at-each-depth/
I am not able to do this after trying more than one hour
this is my function
vector<Btnode> LinkedListHead(Btnode root)
{
queue<Btnode> q;
forward_list l;
Btnode * head=NULL;
Btnode tail=NULL;
q.push(root);
q.push(NULL);
vector<Btnode*> v;
while(!q.empty())
{
Btnode * cur=q.front();
q.pop();
if(cur!=NULL)
{
if(head==NULL)
{
l.push(cur);
}
if(root->left!=NULL)
{
q.push(root->left);
}
if(root->right!=NULL)
{
q.push(root->right);
}
}
else{
l.push(NULL);
q.pop();
v.push_back(head);
if(!q.empty())
{
q.push(NULL);
}
}
}
return v;
}
PLease provide the solution code with explanation in comments
THanks:)