What is more important to know for FAANG interviews: Dijkstras or bellman Ford algorithm?
πŸ‘︎ 32
πŸ’¬︎
πŸ‘€︎ u/googleybruh
πŸ“…︎ Aug 18 2021
🚨︎ report
Why do we iterate V-1 times in Bellman Ford Algorithm?

Relaxing the edges from node 0 to V and using DP should give us the shortest path to each edge. I know BF covers negative cycles, but why exactly do we have to iterate V-1 times to figure out the shortest path and if a negative cycle exists or not? Can someone please explain BF a bit more clearly?

πŸ‘︎ 11
πŸ’¬︎
πŸ‘€︎ u/Bhavishya26
πŸ“…︎ Jun 09 2021
🚨︎ report
What is the pseudocode for finding the all pairs shortest path using specifically the Bellman-Ford's Algorithm?

My professor has asked me to figure out a pseudocode that uses the technique used in Bellman-ford algorithm and find the all pairs shortest paths. The graph contains negative edges and is a directed and weighted graph.

My professor follows the CLRS book and I did read it and found that if you run a single source shortest path algo like the bellman-ford algo V times like for all the vertices, this will find the all pairs shortest path.

Should the pseudocode be like this?

Mod-Bellman-Ford(G,w,s)

Initialise-Single-Source(G,s)

For each vertex v that belongs to V

For i=1 to |G.V|-1

For each edge (u,v) that belongs to G.E

Relax(u,v,w)

For each edge (u,v) that belongs to G.E

If v.d > u.d + w(u,v)

Return False

Return True

Can anybody help me with this? :( i don't know if its correct or not. Just want to verify whether its correct or completely wrong.

πŸ‘︎ 7
πŸ’¬︎
πŸ‘€︎ u/BabaYaga141
πŸ“…︎ May 21 2021
🚨︎ report
[data structures] Time complexity of the Bellman Ford algorithm on weighted DAG's?

So, I've been taught in my class that the Bellman Ford algorithm has a time complexity of O(|v*e|) where v is the number of vertices of a graph and e is the number of edges. Although that time complexity is particularly for a directed weighted graph with a potential cycle, and a negative one at that. So I'm wondering what would the time complexity of the Bellman Ford algorithm be for a weighted directed graph with no cycles? I looked it up, and apparently it is O(|v|+|e|), or linear time. Is this true?

Update: no it's not.

πŸ‘︎ 5
πŸ’¬︎
πŸ“…︎ Nov 15 2020
🚨︎ report
Distance Vector Algorithm (Bellman Ford) - Computerphile youtube.com/watch?v=NdKcj…
πŸ‘︎ 3
πŸ’¬︎
πŸ“…︎ Nov 20 2020
🚨︎ report
Can someone explain Johnson's algorithm and Bellman-ford algorithm?

After reading up on them I am still a bit comfused

πŸ‘︎ 4
πŸ’¬︎
πŸ‘€︎ u/SleepyNutZZZ
πŸ“…︎ Nov 08 2019
🚨︎ report
Question related to Bellman Ford Algorithm

In example from CLSR pg 652, we are getting -2 at the z node, so it must return FALSE as there is negative cycle is present. But it says it will return TRUE.

https://imgur.com/a/SFJn8

πŸ‘︎ 6
πŸ’¬︎
πŸ‘€︎ u/abhi_000
πŸ“…︎ Mar 06 2018
🚨︎ report
Has anyone heard of Bellman's algorithm? (not Bellman-Ford)

As above has anyone heard of so called Bellman's algorithm or recognise the description? I was taking a look through an old course book and came across it. It's a shortest path algorithm whose key benefit was in detecting negative length cycles. Only thing is I can't find any reference to it online. Does anyone have much info on what another name for this algorithm is?

https://preview.redd.it/zfworimwkxr11.jpg?width=2610&format=pjpg&auto=webp&s=4c6a227caf648aec1388ea7e6917bcf65185cbd5

πŸ‘︎ 11
πŸ’¬︎
πŸ‘€︎ u/citizen_kiwi
πŸ“…︎ Oct 13 2018
🚨︎ report
Bellman–Ford Algorithm programmingalgorithms.com…
πŸ‘︎ 23
πŸ’¬︎
πŸ‘€︎ u/abcrink
πŸ“…︎ Jun 24 2016
🚨︎ report
Shortest Path Algorithms (Dijkstra's Algorithm, Breadth-First Search, Bellman-Ford, Floyd-Warshall and Johnson's Algorithm) catonmat.net/blog/mit-int…
πŸ‘︎ 163
πŸ’¬︎
πŸ‘€︎ u/pkrumins
πŸ“…︎ Jan 27 2009
🚨︎ report
Btc-e Bitcoin/Litecoin/Fiat Arbitrager bot. Uses Bellman-Ford algorithm to find profitable cycles of trades. github.com/a-r-d/Bellman-…
πŸ‘︎ 22
πŸ’¬︎
πŸ‘€︎ u/ardme
πŸ“…︎ Nov 21 2015
🚨︎ report
Explanation required on Bellman-Ford Algorithm.

https://imgur.com/a/USLJs

I didn't know where else to post this question so i posted here.

If you look at the first row in the table it says that d(w) is 0, but in the second row it says that d(w) is 2. I'm having a hard time understanding as to why is d(w) = 0 in the first line and 2 in the second? And also when in the real world would someone use a bellman-ford algorithm?

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/the_illumintai
πŸ“…︎ Mar 23 2018
🚨︎ report
TIL The Bellman-Ford algorithm was first proposed by Alfonso Shimbel in 1955, but is instead named after Richard Bellman and Lester Ford, Jr., who published it in 1958 and 1956, respectively. en.wikipedia.org/wiki/Bel…
πŸ‘︎ 17
πŸ’¬︎
πŸ‘€︎ u/bragi92
πŸ“…︎ Apr 16 2017
🚨︎ report
Can anyone elif5 Bellman–Ford algorithm in the context of trading?
πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/john_legend_
πŸ“…︎ Jan 03 2018
🚨︎ report
Is this the correct way to demonstrate proof by contradiction for the optimal substructure property of the Bellman Ford Algorithm?

I am watching a video on coursera and the following case was stated to be obvious by contradiction.

Let G = (V,E) be a directed graph with edge lengths C(e) and source vertex s. For every v in set V and i less than |v| let P = shortest s-v path with at most i edges.

Case 1: If P has <= (i - 1) edges, it is a shortest s-v path with <= (i - 1) edges.

My attempt at proof by contradiction is:

Suppose P is a shortest S-V path and has greater than (i-1) edges. Then P is a shortest path with >(i-1) and <=(i-1) edges. It cannot be the case that P has both >(i-1) and <=(i-1) edges, and so P must have <=(i-1) edges. This seems kind of silly to me.

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/DIYjackass
πŸ“…︎ Jan 22 2018
🚨︎ report
ELI5: Dijkstra's algorithm or the Bellman Ford algorithm

I understand how to implement A*, but I don't understand the theory behind it, and I don't understand these two algorithms at all

πŸ‘︎ 2
πŸ’¬︎
πŸ“…︎ May 22 2013
🚨︎ report
[Java] Bellman-Ford Distance Vector Algorithm

I'm trying to code a program for a class that simulates a router and so far I have the basics set up ("router" can send and receive packets through an emulated server to other "routers" connected to the server). Each packet contains only the distance vector for that router. When a router receives a packet it is supposed to update it's own distance vector accordingly using the bellman-ford algorithm. The problem i'm having is that I am finding myself unable to implement the actual algorithm without cheating and using an adjacency matrix.

For example, say I have 3 routers connected as follows:

A ---1--- B ---2--- C

That is, A and B are connected with a link cost of 1, and B and C are connected with a link cost of 2. So when the routers are all started, they will send a packet to each of their directly connected neighbors containing their distance vector info. So A would send router B (0, 1, INF), B would send A and C (1, 0, 2) and C would send B (INF, 2, 0) where INF means the 2 routers are not directly connected.

So lets look at router A receiving a packet from router B. To calculate the minimum costs to each other router using the Bellman-Ford algorithm is as follows.

Mincost(a,b) = min((cost(a,b) + distance(b,b)),(cost(a,c) + distance(c,b))

Mincost(a,c) = min((cost(a,b) + distance(b,c)),(cost(a,c) + distance(c,c))

So the problem I am running into is that I cannot for the life of me figure out how to implement an algorithm that will calculate the minimum path for a router to every other router. It's easy enough to make one if you know exactly how many routers there are going to be but how would you do it when the number of routers can be arbitrarily big?

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/Nantook
πŸ“…︎ Nov 22 2012
🚨︎ report
ELI5: Bellman-Ford Algorithm and Dijkstra's Algorithm

I understand what they are for, and I even implemented Dijkstra's in some code a while back, but I am having a hard time wrapping my head around the Bellman-Ford Algorithm. Is there a heuristic to understand it?

πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/LeonardTimber
πŸ“…︎ Feb 11 2013
🚨︎ report
[R] Logistic Q-Learning: They introduce the logistic Bellman error, a convex loss function derived from first principles of MDP theory that leads to practical RL algorithms that can be implemented without any approximation of the theory. arxiv.org/abs/2010.11151
πŸ‘︎ 138
πŸ’¬︎
πŸ‘€︎ u/hardmaru
πŸ“…︎ Oct 22 2020
🚨︎ report
"Logistic Q-Learning", Bas-Serrano et al 2020 (They introduce the logistic Bellman error, a convex loss function derived from first principles of MDP theory that leads to practical RL algorithms that can be implemented without any approximation of the theory.) arxiv.org/abs/2010.11151
πŸ‘︎ 8
πŸ’¬︎
πŸ‘€︎ u/gwern
πŸ“…︎ Oct 22 2020
🚨︎ report
Below you will find a link to a Zoom recording where our team discusses Reinforcement Learning. Topics covered: Markov Decision Process, Double Q-Learning, the math behind Q-Learning, and the Bellman Equation. We also walk through the algorithms and provide coded examples.

Topic: Reinforcement Learning Math Discussion

Meeting Recording:

https://us02web.zoom.us/rec/share/xcdlLPLzrmxLfNbNuFHud4UtFaTVeaa823IYr6dYzUw-uzo3Q0gjSQwweD9oLgzf

πŸ‘︎ 41
πŸ’¬︎
πŸ‘€︎ u/davidstroud1123
πŸ“…︎ May 19 2020
🚨︎ report
Bellman-Ford for Gold #2

I did Bellman-Ford for Gold #2 because it seemed pretty obvious. However, I ended up doing N-1 relaxations which were unnecessary after thinking about it after the contest was over. Then, I realized that you only need K-1 relaxations. Is this approach correct?

K < 50

N < 50000

With these numbers, doing K-1 relaxations seems to be 1000x faster than N-1 relaxations which seems like a great optimization. I only got test cases 1, 2, 3, 5 with the N-1 relaxations method. Will I get all the test cases with K-1 relaxations? The thing about relaxations in Bellman-Ford is, is that if you go over the optimal number of relaxations, you'll still get the correct answer, but slower so I could technically set the for loop to go to a max of 50 relaxations which is still pretty fast.

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/lopkiloinm
πŸ“…︎ Jan 26 2021
🚨︎ report
Bellman–Ford ftw
πŸ‘︎ 300
πŸ’¬︎
πŸ‘€︎ u/thirstyboye69
πŸ“…︎ Apr 11 2019
🚨︎ report
[P] Implementation of DeepMind's Distributional Bellman and the C51 Algorithm flyyufelix.github.io/2017…
πŸ‘︎ 17
πŸ’¬︎
πŸ‘€︎ u/hardmaru
πŸ“…︎ Nov 02 2017
🚨︎ report
[Assignment 3] Bellman-Ford Expected Outputs

If you want to test your Bellman-Ford algorithm and want to know what the expected output is for each file:

https://preview.redd.it/zb8qc5ydgiz31.png?width=1568&format=png&auto=webp&s=6545e0d5509b882bffb8aa438b3dac1452c972ad

https://preview.redd.it/6hp8m80ggiz31.png?width=1590&format=png&auto=webp&s=281b86bd359e82c07101884f0903cdeca34f81ba

https://preview.redd.it/h3yis0dhgiz31.png?width=1528&format=png&auto=webp&s=9d3b26fa7c82975aa12ef68b50120fb6e6333d09

https://preview.redd.it/d4ke8vsigiz31.png?width=1553&format=png&auto=webp&s=8bd4479a0c11ed610c755e10442b62e7a5901bc8

I might make more testers later on (if I have time) and I'll post them here too

πŸ‘︎ 30
πŸ’¬︎
πŸ‘€︎ u/knownoman
πŸ“…︎ Nov 18 2019
🚨︎ report
After watching the β€œHow Ford Solved the Crossover Problem” video yesterday πŸ™„ Nice try algorithm, I’m not interested in purchasing lol
πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/Clammy_fern
πŸ“…︎ Jan 04 2022
🚨︎ report
Rusty Russell on lightning routing: Routing, Dijkstra, Bellman-Ford and BFG! medium.com/@rusty_lightni…
πŸ‘︎ 63
πŸ’¬︎
πŸ‘€︎ u/thorjag
πŸ“…︎ Jun 01 2016
🚨︎ report
SΓ€ger ni ”en norsk, en tysk och Bellman” eller ”en norsk, en tysk och *en* Bellman?”

Min Γ₯sikt Γ€r att alla som sΓ€ger ”en Bellman” bΓΆr tvΓ₯ngsomhΓ€ndertas av Svenska Akademien.

Diskutera i grupp och Γ₯terkom.

EDIT: Nationaliteter diskuterar vi imorgon.

πŸ‘︎ 266
πŸ’¬︎
πŸ“…︎ Jan 05 2022
🚨︎ report
A practical treatise on pairs trading, Bellman-Ford, Shannon’s Demon, and order book pressure: Tales from 18 months of cryptocurrency arbitrage ddmckinnon.com/2019/04/24…
πŸ‘︎ 5
πŸ’¬︎
πŸ‘€︎ u/dmckinno
πŸ“…︎ May 07 2019
🚨︎ report
algo: is ford fulkerson algorithm the hardest thing to understand so far

i cant be the only one.

πŸ‘︎ 18
πŸ’¬︎
πŸ‘€︎ u/Far-Safety-1165
πŸ“…︎ Oct 20 2021
🚨︎ report
ELI5: Bellman-Held-Karp algorithm process? For traveling salesman problem

I cannot find an easily consumable explanation of the process here, and how it manages to run faster than N! time for traveling sales person problem for a Hamiltonian cycle where shortest path S(s,v) where S is the start vertex and v is the destination vertex. But s=v

Starts and finishes at same vertex

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/relaxus2maxus
πŸ“…︎ Apr 24 2014
🚨︎ report
Bellman Ford with at most k-edges

Hello all,

I try to wrap my head around a extended version of the Bellman Ford shortest path algorithm. In k iterations the standard Bellman Ford algorithm can produce shortest path using more than k edges.

Here is a fairly naive idea that uses k-iterations of the standard algorithm:

  • In the i-th iteration only nodes that are not more than i edges away from the starting node, will be considered. Eg: In the first iteration only the nodes that are adjacent to the starting node, in the second iteration the nodes above plus the nodes that are adjacent to the prior.
  • Edge relaxation is only allowed when the resulting path does not use more edges.

This should be easy to implement. Do you think this will work, or are there any flaws that I have overseen?

πŸ‘︎ 4
πŸ’¬︎
πŸ‘€︎ u/Colonist666
πŸ“…︎ Nov 13 2017
🚨︎ report

Please note that this site uses cookies to personalise content and adverts, to provide social media features, and to analyse web traffic. Click here for more information.