what dose parent[node]!=nbr means
Confused plss help
Hey @adarshsingh2k
consider this -> 1–2–3–4
let say u started running dfs from 1 so u marked it visited then u checked for its neighbors .
it is 2 and not visited , so u call on 2, now again from u check all its neigbour (1 and 3).
here 1 is visited right? as per logic visited neigbour node means cycle right? ,but it fails here why? becuase 1 is parent node.
so here we have 2 things to consider for cycle ->
a) neighbour node must be visited
b) it should not be a parent node