Timeline for Dijkstra's algorithm: why are distances initialized to infinity and not some negative number?
Current License: CC BY-SA 3.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Mar 14, 2018 at 8:55 | comment | added | Peter Taylor |
On a practical point, it's common to use INT_MAX >> 1 to represent infinity. Certainly you want to do this if using an adjacency matrix instead of adjacency lists, because it means that you save a special case by not needing to worry about overflow.
|
|
Mar 13, 2018 at 16:55 | vote | accept | Tazik_S | ||
Mar 13, 2018 at 10:32 | answer | added | Raphael | timeline score: 4 | |
Mar 13, 2018 at 10:28 | history | edited | Raphael |
edited tags
|
|
Mar 13, 2018 at 1:06 | comment | added | Derek Elkins left SE |
C++ int s take up the same amount of space regardless of their value.
|
|
Mar 13, 2018 at 1:03 | review | First posts | |||
Mar 13, 2018 at 1:07 | |||||
Mar 13, 2018 at 0:59 | history | asked | Tazik_S | CC BY-SA 3.0 |