Topological sort BFS graph

If value of a node is greater than number of nodes then we can’t do this. Why??

Suppose we take 6 nodes , values - 0,1,2,4,7,8
then this won’t work.

@anishanand3733 hey basically we are numbering node from 0 to total number of nodes and that logic is in building of graph and yhi logic sari graph building me lagta hai ad if you want ki random number se ho to apko graph building method change krna pdega apna and in place of seq number of node take the number you want to put in that node and build graph from that logic it will work.

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.