1/4
Looks like no tags are added yet.
BFS
Q ← [s]
visited[s] ← true
while Q not empty:
u ← dequeue(Q)
for v in adj[u]:
if not visited[v]:
visited[v] ← true
enqueue(Q,v)O (V + E)
DFS
explore(u):
visited[u] ← true
for v in adj[u]:
if not visited[v]:
explore(v)O (V + E)
Kruskal
sort edges by weight
for (u,v) in sorted edges:
if Find(u) != Find(v):
add edge (u,v)
Union(u,v)O (E Log E)
Prim
key[s] ← 0
all other keys ← ∞
repeat:
u ← unvisited vertex with minimum key
add u to tree
for unvisited neighbor v:
key[v] ← min(key[v],weight(u,v))O ((E + V) log v)
Dijkstra
dist[s] ← 0
all other dist ← ∞
while priority queue not empty:
u ← extractMin()
for (u,v,w):
if dist[u]+w < dist[v]:
dist[v] ← dist[u]+wO ((E + V)log v)