Question

Let G (V, E) be a directed graph with n vertices and m edges. It is known that in dfsTrace of G the function dfs is called n

0 0
Add a comment Improve this question Transcribed image text
Answer #1

First, dfsTrace calls the dfs function n times. Now, inside each dfs call, there is a loop whose body gets executed once for each edge. Hence the number of times the loop runs is exactly m. Hence, the runtime of each dfs call is \Theta(m). Thus, the total time complexity for the dfsTrace function is n \cdot \Theta(m) = \Theta(n \cdot m) .

This is the worst case complexity of the dfsTrace function.

Comment in case of any doubts.

Add a comment
Know the answer?
Add Answer to:
Let G (V, E) be a directed graph with n vertices and m edges. It is known that in dfsTrace of G t...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT