Dijkstra's Algorithm Exercise: Find the Solution!

  • MHB
  • Thread starter evinda
  • Start date
  • Tags
    Algorithm
In summary, the conversation discusses using an algorithm to find the least costly route for grandpa to reach his parking spot while navigating through various obstacles that have different point values. The question of whether revisiting a spot costs additional points is also raised.
  • #1
evinda
Gold Member
MHB
3,836
0
Hi! (Smile)

Could you give me a difficult exercise that is related to the Dijkstra's algorithm? (Blush)
 
Technology news on Phys.org
  • #2
evinda said:
Hi! (Smile)

Could you give me a difficult exercise that is related to the Dijkstra's algorithm? (Blush)

Hey! (Blush)

gz1.jpg


Grandpa starts at the right top and wants to reach his parking spot on the left top.

Each step costs 1 point.
Eating candy restores 3 points.
Running into a monster costs 5 points.
Moving through the spot with the coffin takes 2 points.
And if grandpa tries to move through the spot with the jelly, it takes him 10 points to get through the sticky goo.

How should we apply an algorithm to find the least costly route? (Wondering)
 
  • #3
I like Serena said:
Hey! (Blush)
Grandpa starts at the right top and wants to reach his parking spot on the left top.

Each step costs 1 point.
Eating candy restores 3 points.
Running into a monster costs 5 points.
Moving through the spot with the coffin takes 2 points.
And if grandpa tries to move through the spot with the jelly, it takes him 10 points to get through the sticky goo.

How should we apply an algorithm to find the least costly route? (Wondering)

Does it cost points to visit a spot you'e previously visited. So if you go from $a$ to $b$ to $c$ that would be $-3$ but if you went back to $b$ from $c$ would that cost another point? ($-4$) or no?
 
  • #4
shamieh said:
Does it cost points to visit a spot you'e previously visited. So if you go from $a$ to $b$ to $c$ that would be $-3$ but if you went back to $b$ from $c$ would that cost another point? ($-4$) or no?

Riding from $a$ to $b$ to $c$ would be $-2$, since it's 2 steps.
Riding back from $c$ to $b$ will tire grandpa more, so it will indeed cost another point ($-3$). (Mmm)
 

Related to Dijkstra's Algorithm Exercise: Find the Solution!

1. What is Dijkstra's Algorithm?

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

2. How does Dijkstra's Algorithm work?

Dijkstra's Algorithm works by starting at the source node and exploring all adjacent nodes, assigning each a tentative distance. It then moves to the node with the lowest tentative distance and repeats the process until the destination node is reached.

3. What is the time complexity of Dijkstra's Algorithm?

The time complexity of Dijkstra's Algorithm is O(E+VlogV), where E is the number of edges and V is the number of vertices. This makes it an efficient algorithm for finding shortest paths in large graphs.

4. What are some applications of Dijkstra's Algorithm?

Dijkstra's Algorithm has many applications, including finding the shortest route in transportation networks, optimizing network routing, and solving the shortest path problem in computer science.

5. Are there any limitations to Dijkstra's Algorithm?

Yes, Dijkstra's Algorithm only works for graphs with non-negative edge weights and does not handle negative cycles. It also does not consider other factors such as traffic or road closures, which may affect the shortest path in real-world scenarios.

Similar threads

  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
6
Views
1K
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
8
Views
2K
  • Programming and Computer Science
Replies
14
Views
2K
Replies
9
Views
1K
  • Programming and Computer Science
Replies
7
Views
1K
  • Programming and Computer Science
Replies
3
Views
1K
Back
Top