educative.io

Rec_node_stack in detecting cycle

What is the intuition behind rec_node_stack? Both visited and rec_node_stack looks same. Is there any scenario when they both are different?


Type your question above this line.

Course: https://www.educative.io/collection/5642554087309312/5634727314718720
Lesson: https://www.educative.io/collection/page/5642554087309312/5634727314718720/5641906755207168

Hi @Vamsi_Kilaru

rec_node_stack is the memory used to store every node we are going to visit whereas visited will have a list of visited nodes.
Former can have the same node multiple times as we may visit a single node more than one times (from a different path) whereas later is used as a final entry for a node that has been visited.