Is A→E→D→F a valid solution for Dijkstra's algorithm?

  • I
  • Thread starter Erenjaeger
  • Start date
  • Tags
    Algorithm
In summary, the solution in the video is A→B→D→F, but both A→B→D and A→E→D have a distance of 9. This means that when reaching D, the predecessor could be either B or E, and the cost on the path so far is 9. The solution A→E→D→F is also correct, but A→B→D was chosen because it was evaluated earlier and A→E→D does not improve upon it. This decision was not mentioned in the video.
  • #1
Erenjaeger
141
6


In this video the solution is: A→B→D→F
but the paths A→B→D and A→E→D both have a distance of 9, so when you get to D you can either have [B,9] or [E,9] where the first entry is the predecessor and the second entry is the 'cost' on that path so far, or here the distance.
is the solution A→E→D→F also correct or is there some reason that he chose the path A→B→D→F?
 
Physics news on Phys.org
  • #2
Erenjaeger said:


In this video the solution is: A→B→D→F
but the paths A→B→D and A→E→D both have a distance of 9, so when you get to D you can either have [B,9] or [E,9] where the first entry is the predecessor and the second entry is the 'cost' on that path so far, or here the distance.
is the solution A→E→D→F also correct or is there some reason that he chose the path A→B→D→F?


Hi Erenjaeger! :)

Yes, A→E→D→F is also correct.
The only reason to pick A→B→D is just because it was evaluated earlier, and A→E→D does not improve on it.
It seems that this decision was skipped in the explanation in the video.
 
  • Like
Likes Erenjaeger

What is Dijkstra's algorithm?

Dijkstra's algorithm is a graph search algorithm used to find the shortest path between two nodes in a weighted graph. It was developed by Dutch computer scientist Edsger Dijkstra in 1956.

How does Dijkstra's algorithm work?

The algorithm works by maintaining a list of unvisited nodes and their distances from the starting node. Then, it iteratively selects the node with the smallest distance and updates the distances of its neighboring nodes. This process continues until the shortest path to the target node is found.

What is the time complexity of Dijkstra's algorithm?

The time complexity of Dijkstra's algorithm is O(|E| + |V|log|V|), where E is the number of edges and V is the number of vertices in the graph. This is because the algorithm uses a priority queue to select the next node with the smallest distance, which has a time complexity of O(log|V|).

Can Dijkstra's algorithm handle negative edge weights?

No, Dijkstra's algorithm cannot handle negative edge weights. This is because the algorithm relies on the assumption that the shortest path is composed of edges with non-negative weights. If there are negative edge weights, the algorithm may produce incorrect results.

What are the applications of Dijkstra's algorithm?

Dijkstra's algorithm has various applications in network routing, transportation planning, and GPS navigation. It is also commonly used in computer science for pathfinding in video games and search algorithms in artificial intelligence.

Similar threads

  • Set Theory, Logic, Probability, Statistics
Replies
2
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
6
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
2
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
12
Views
1K
  • Programming and Computer Science
Replies
2
Views
633
  • Calculus and Beyond Homework Help
Replies
18
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
4
Views
1K
  • Introductory Physics Homework Help
Replies
1
Views
131
  • Set Theory, Logic, Probability, Statistics
Replies
7
Views
339
Back
Top