Machine-translated by Google. Questions are authored in English.
Top

Discussion

In the ............. traversal, we visit all of a vertex's descendants before we move on to an adjacent vertex.

  • A.Breadth First
  • B.Depth First
  • C.Inorder
  • D.Preorder

Answer: B

This is depth first traversal.

Depth-first traversal goes as deep as possible along each branch: from a vertex it visits an unvisited neighbour, then that neighbour's descendants, and only after exhausting them backtracks to try the next adjacent vertex.

Breadth-first traversal does the opposite, visiting all adjacent vertices before going deeper. Inorder and preorder are particular orders for visiting the nodes of a binary tree, not the general graph traversal the question describes.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.