C
C#13mo ago
Anou212

❔ I wrote a program that calculates the shortest path to move fridge to a certain place but its slow

I wrote a program that calculates the shortest path to move fridge to a certain place but the runtime is too long. This is the code:
7 Replies
Mango
Mango13mo ago
I can't seem to open that message on mobile right now, but what algorithm are you using? @Anou212 I would look into the A* algorithm
Denis
Denis13mo ago
A* search algorithm
A* (pronounced "A-star") is a graph traversal and path search algorithm, which is used in many fields of computer science due to its completeness, optimality, and optimal efficiency. One major practical drawback is its


O (
b
d

)

...
Denis
Denis13mo ago
Very cool! Whenever I would think of "find shortest path", Dijkstra would come to my mind.
Anou212
Anou21213mo ago
it is for a school project and they said we had to make use of BFS, does this comply?
Mango
Mango13mo ago
Ah no A* does not apply to breadth first. Breadth first is not the most efficient algorithm ever, if it's a bit slow that is a bit to be expected Unfortunate I can't see your code atm someone who can might visit this thread. However, make sure your code is doing this: Starts at root node If applicable: Visits all the children nodes Then from left to right again, visit the child nodes Dijkstra plays a huge part in A* . I studied AI for a bit in school, all these basic traversal algorithms pretty much originate from him
Denis
Denis13mo ago
Yeah, I looked it up. At uni they only taught us Dijkstra
Accord
Accord13mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.