we check the stack top for return to the previous node and check if it has any unvisited nodes herewe find to be on the top of the stack only unvisited adjacent node is from is now so we visit cmark it as visited and put it onto the stack as does not have any unvisited adjacent node so we keep popping the stack until we find node that has an unvisited adjacent node in this casethere' none and we keep popping until the stack is empty