Single Choice Easy

QWhat is the time complexity of a breadth-first search (BFS) algorithm on a tree with N nodes?

ID: #15256 Time Complexity 160 views
Question Info
#15256Q ID
EasyDifficulty
Time ComplexityTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A O(1)
  • B O(log N)
  • C O(N)
  • D O(N^2)
Correct Answer

Explanation

In a breadth-first search (BFS) algorithm on a tree, each node is visited exactly once, and each edge is traversed once. As a tree has N-1 edges for N nodes, the time complexity of BFS on a tree is proportional to the number of nodes, denoted as O(N).

Share This Question

Challenge a friend or share with your study group.