Time Complexity · #9 · 2026-04-13
What's the Big-O?
Python ·Difficulty 2/3
How to play
Read the code and pick its time complexity from four Big-O choices. Think about loops, recursion, and hidden costs. Press 1–4 or click to answer.
Graph with V vertices and E edges. What is the time complexity?
from collections import deque
def bfs(graph, start):
visited = set()
queue = deque([start])
while queue:
node = queue.popleft()
if node in visited:
continue
visited.add(node)
for neighbor in graph[node]:
queue.append(neighbor)
return visited
Loading your progress...
Press 1 through 4, or tap a numbered choice, to answer. Back to hub