In a depth-first search, what happens when a node is visited?

Practice Questions

Q1
In a depth-first search, what happens when a node is visited?
  1. It is added to the queue.
  2. It is marked as visited and all its adjacent nodes are explored.
  3. It is removed from the graph.
  4. It is added to the stack.

Questions & Step-by-Step Solutions

In a depth-first search, what happens when a node is visited?
  • Step 1: Start at the initial node.
  • Step 2: Mark the current node as visited to keep track of it.
  • Step 3: Look at all the nodes that are directly connected to the current node (these are called adjacent nodes).
  • Step 4: For each adjacent node that has not been visited yet, go to that node and repeat the process from Step 2.
No concepts available.
Soulshift Feedback ×

On a scale of 0–10, how likely are you to recommend The Soulshift Academy?

Not likely Very likely