❔ 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
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
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
)
...
O (
b
d
)
...
Very cool! Whenever I would think of "find shortest path", Dijkstra would come to my mind.
it is for a school project and they said we had to make use of BFS, does this comply?
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
Yeah, I looked it up. At uni they only taught us Dijkstra
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.