Data structures and algorithms
Your shortest-path graph has some negative edge weights but no negative cycles.
AppliedMultiple choice
Your shortest-path graph has some negative edge weights but no negative cycles. What do you use?
- ABellman–Ford, at
- BDijkstra, which handles any weights
- CDijkstra after adding a constant to every weight
- DBreadth-first search, since the graph is finite
The worked solution is in Premium
The answer, the full working and the one idea to take away – for this and all 1,322 questions in the bank. Answer it in practice and your working is marked, with a known mistake named when you make one.
Report an issue with this question
Learn the method
Of the kind reported at
Optiver, Citadel Securities, Hudson River Trading, Jump Trading
More data structures and algorithms questions
- With both union by rank and path compression, what is the amortised cost of a…Advanced · Premium
- Converting between currencies, part 3 of 3Expert · Premium
- What is the maximum number of edges in a directed acyclic graph on ten vertices?Foundation · Premium
- A dependency graph has edges a → b, a → c, b → d, c → d.Foundation · Premium
- Converting between currencies, part 1 of 3Foundation · Premium
- What is the running time of Dijkstra’s algorithm with a binary heap, on a graph…Applied · Premium