Snakes and Ladders

Why are we doing g.addEdge(36. 36) ? It’s said in the video that the 36th node is not recognized that’s why, but in the while loop of BFS function, some other node (such as 35) would have pushed 36 in the queue, thus 36 is pushed to the queue then why are we adding a self edge separately?

hello @pratyush34
please mention the timestamp where this was said

At 14:45, it is said that adding an edge (36, 36) will tell the graph that there is a node 36 but other connected nodes of 36 such as 35, 34 etc will also tell the graph about node 36, itsn’t it?

yeah u r right,
u should try without adding self loop. it should work i guess.

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.