Here again is the pseudocode for Dijkstra’s algorithm:
S = { }; F = {v}; v.d = 0;
while (F ≠ {}) {
f = node in F with min d value;
Remove f from F, add it to S;
for each neighbor w of f {
if (w not in S or F) {
w.d = f.d + weight(f, w);
add w to F;
} else if (f.d+weight(f,w) < w.d) {
w.d = f.d+weight(f,w);
}
}
}
Analyze the runtime of Dijkstra’s algorithm, implemented as described in the lecture videos. Give the worst-case runtime, except you may assume that hash table operations run in O(1).