Single Choice
Easy
QWhat is the time complexity of a depth-first search (DFS) algorithm on a tree with N nodes?
ID: #15257
Time Complexity
147 views
Question Info
#15257Q ID
EasyDifficulty
Time ComplexityTopic
Your Answer
Choose the Best Option
Click any option to instantly check if you're correct.
Correct Answer
Explanation
In a depth-first search (DFS) 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 DFS on a tree is proportional to the number of nodes, denoted as O(N).
Continue Practice
Share
Share This Question
Challenge a friend or share with your study group.
More from This Topic