Like GPS: you know where you are (distance 0), everything else is unknown.
Start with distance 0 for the source. All others are unknown (∞). Queue contains [A, 0].
> dist: {A:0, B:∞, C:∞, D:∞}
> pq: [[0,A]]Like GPS: you know where you are (distance 0), everything else is unknown.
Start with distance 0 for the source. All others are unknown (∞). Queue contains [A, 0].
> dist: {A:0, B:∞, C:∞, D:∞}
> pq: [[0,A]]Sign in to cast your vote
Sign in to share your feedback and join the discussion.