79124121

Date: 2024-10-25 02:56:17
Score: 0.5
Natty:
Report link

I am not a huge expert so take my reply with a grain of salt, but I did just recently use some pathing algorithms. Firstly, O() notation isn't exact, so for example -1 isn't really relevant in the grand scheme of things, etc. The way I see it, you have a for loop, that's at least O(N), where n represents a node (which is a better way to look at it). Dijkstra's when used in path finding is applied to a 2D grid, where each square is a node , and the distance of that node from the starting node (via its neighbours) is calculated as you go. Therefore if you see the vertex as the nodes position in the grid and the edges as the distance, then O(VE) is equivalent roughly to O(N), as each node only has 8 neighbours (edges), so it isn't running in O(N^2) unless you have a tiny grid. On a graph however, that is not true at all, you could have a fully connected graph with thousands of nodes (each with N-1 neighbours).

What I mean to say is, the O() notation is somewhat meaningless without the context.

I hope that way of thinking about it and helps a little bit!

Reasons:
  • Long answer (-1):
  • No code block (0.5):
  • Low reputation (1):
Posted by: K_wrecks