Complexity Initialize: dist(s)=0;dist(u)=oo for all other u ■Q=[s] -1 While Q is not empty Dequeue the top element u of Q -1 For all neighbors v of u,if dist(v)=o, enqueue(v) 1 ■dist()=dist(u)+1 -1 oIf t is found,then stop and output dist(t) .1 ·Total:V\+∑u∈vlN(u)川=O(IV\+IEl) 21Complexity ◼ Initialize: ❑ 𝑑𝑖𝑠𝑡(𝑠) = 0; 𝑑𝑖𝑠𝑡(𝑢) = ∞ for all other 𝑢 - |𝑉| ◼ 𝑄 = [𝑠] - 1 ◼ While 𝑄 is not empty ❑ Dequeue the top element 𝑢 of 𝑄 - 1 ❑ For all neighbors 𝑣 of 𝑢, if 𝑑𝑖𝑠𝑡(𝑣) = ∞, -𝑁(𝑢) ◼ enqueue(𝑣) - 1 ◼ 𝑑𝑖𝑠𝑡(𝑣) = 𝑑𝑖𝑠𝑡(𝑢) + 1 - 1 ❑ If 𝑡 is found, then stop and output dist(t) - 1 ◼ Total: 𝑉 + σ𝑢∈𝑉 |𝑁(𝑢)| = 𝑂(|𝑉| + |𝐸|) 21