C
C#2y 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
Mango2y 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
Denis2y 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
Denis2y ago
Very cool! Whenever I would think of "find shortest path", Dijkstra would come to my mind.
Anou212
Anou212OP2y ago
it is for a school project and they said we had to make use of BFS, does this comply?
Mango
Mango2y 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
Denis2y ago
Yeah, I looked it up. At uni they only taught us Dijkstra
Accord
Accord2y 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.
Want results from more Discord servers?
Add your server