only printing 1 value
Plz check the code for hamiltonian path and cycle
can u explain what was the error?
Sure, assume you go from 0 to 2, then your visited vector is {true,true} which denotes that 0 and 1 are visited (but actually 0 and 2 are visited), so I have corrected that part.
but we are comparing the size then why need to check by loop?because after completing all its neighbours of a node we are making it false then why
Push_back is logically incorrect,
lets say you have visited 0,1,6
then visited should be {1,1,0,0,0,0,1}
but your visited will be {1,1,1}(which says 0,1,2 are visited)
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.