Skip to content
This repository has been archived by the owner on Apr 29, 2020. It is now read-only.

O(VE) in bfs.py #83

Open
harshuljain13 opened this issue May 11, 2016 · 1 comment
Open

O(VE) in bfs.py #83

harshuljain13 opened this issue May 11, 2016 · 1 comment

Comments

@harshuljain13
Copy link

while queue: node = queue.pop(0) if node not in visited: visited.add(node)

this takes time complexity of O(VE) rather than O(V+E)

@goelakash
Copy link
Collaborator

It will be O(V^2). We need a visited array to mark such nodes.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants