Getting segmentation fault

hello @premang
your logic for bfs is correct.
make sure u r giving input in correct order.
also it is working fine on the input u mentioned in ur code