r/backtickbot • • Jun 15 '21

https://np.reddit.com/r/learnpython/comments/o0gb9x/whats_the_complexity_of_this_bfs_graph_traversal/h1uyx36/

I think O(V + E) is right if we are not inputting the vertices/nodes. It won't depend on the input, so it can be considered O(1).

This is just like

l = [2, 3, 5]
for i in l:
    print(i)

which is O(1) and doesn't depend on the length of the list.

Don't know for sure, though.

0 Upvotes

0 comments sorted by