Level order printing using queue<pair<Node,int>>

not able to get the logic of queue<pair<Node,int>>.
can u identify and correct where i am going wrong

if the logic of
queue<Node*> is clear to u
then this is simply a extension
where for each node u are defining the level for each node

to know about pair in c++

i dont understand anything

i just know how to use queue and pairs.

okay so
i think u have little idea about level order traversal
u recommend watching
image
this is from ur course

using a queue
u add the root node first in the queue ( q)
then
till q is not empty()
u are printing the node and then u insert its left and right child into the queue

( please watch the video in sequence) u`ll understand better

but now u have the level order traversal but u are not able to make distinction b/w the levels
so
for that reason u are basically taking a queue<pair<Node*, int>> that records the node as well as the level at which the node occurs
while removing the node from the queue whenever u encounter a node with distinct level u add a new line(\n) character so that u can distinctly identify b/w different levels

whenever u encounter a node with distinct level u add a new line(\n).

how do we know that we are changing level thats my question

At time stamp 1:20 in video, how to program that this is level 1, this is L+1 and so on.

wait i `ll make update in ur code

addded comments in bfs_q function