Shortest Path Algorithms Explained (Dijkstra's & Bellman-Ford)

  Рет қаралды 33,049

b001

b001

24 күн бұрын

To further enhance your computer science knowledge, go to brilliant.org/b001 to start your 30-day free trial and get 20% off an annual premium subscription.
If you want to experiment with the algorithms yourself, I've included some Python scripts on my Patreon: / b001io
💬 Discord: / discord
🐦 Follow me on Twitter: / b001io
🔗 More links: linktr.ee/b001io

Пікірлер: 58
@MoeSalamaIbrahim
@MoeSalamaIbrahim 22 күн бұрын
Throughout this year's courses in my master's degree in electrical engineering, I've encountered Dijkstra's algorithm in almost all of my courses. I've never ceased to keep searching for explanations and perspectives of it, given my non-CS background but the sheer number of applications to this algorithm. Also, this year has made your channel one of my most enjoyable sources of informative relief. Thank you sir.
@CraftingCake
@CraftingCake 21 күн бұрын
What specialty did you do in your masters? I have a bachelor in electrical engineering and we never talked about algorithms at all. I would even say, this is what differentiates me the most compared to computer science students.
@landchannel7688
@landchannel7688 20 күн бұрын
10:25 Ok but the idea of an electric car just going in circles between charging stations, hogging up more and more charge is genuinely funny.
@Blaze_0101
@Blaze_0101 22 күн бұрын
00:01 Finding the shortest, optimized path is crucial in daily life. 01:32 Dijkstra's algorithm is a key solution method for finding shortest paths. 03:01 Using Min Heap priority queue to find shortest paths efficiently 04:48 Dijkstra's algorithm finds the shortest path 06:36 Dijkstra's algorithm cannot handle negative weighted edges 08:22 Finding shortest paths using relaxation technique. 10:08 The Bellman Ford algorithm can identify negative weight cycles in a graph. 11:42 Negative weight cycle problem is an ongoing area of research. Crafted by AI ?
@adhitamaputra-73
@adhitamaputra-73 18 күн бұрын
: : gajah mada #poxi #coin #boxi #asia #osis #intel #sony #linux sumarecone : : europe_negara@keraton
@dlv5652
@dlv5652 22 күн бұрын
I was just thinking about this! Thank you
@DeokbaeKwak
@DeokbaeKwak 21 күн бұрын
Best video to watch 3 days before my data structure exam
@deependrakumar5239
@deependrakumar5239 20 күн бұрын
Bro this is algorithm not data structure 😂
@DeokbaeKwak
@DeokbaeKwak 19 күн бұрын
@@deependrakumar5239 My lecture covers graph search algorithms 🙂‍↔️
@DeokbaeKwak
@DeokbaeKwak 16 күн бұрын
@@deependrakumar5239 It includes search algorithms related with various data structures bruh
@deependrakumar5239
@deependrakumar5239 16 күн бұрын
I understand your feeling brother, but we use algorithm in data structure to make effective and scalable code.
@DeokbaeKwak
@DeokbaeKwak 16 күн бұрын
@@deependrakumar5239 I get it. I just wanted to say that this video helped me understand the algorithm much better
@robinsonrojaslopez5200
@robinsonrojaslopez5200 18 күн бұрын
I don't know much about how the algorithm works, but if you are looking for the smallest value, I understand that it cannot be less than zero since this way you would avoid the problem of entering a cycle in which the value is decreased. infinitely, to prevent the value from being less than zero you can look at what the weights are and look for the smallest one, in the first example -30, and add the absolute weight in the rest in this way this node (and the others with existing negative values) has a value equal to or greater than zero and the problem is avoided.
@Idan_Nesimov
@Idan_Nesimov 21 күн бұрын
Great content young man !
@TheGoldenPro
@TheGoldenPro 22 күн бұрын
OMG he's alive!
@chri-k
@chri-k 18 күн бұрын
One thing: for Dijkstra's algorithm, if you're going to visit every node (so, if you have a small-ish graph), there's no reason to use a min heap
@marvinchuakhaichien2361
@marvinchuakhaichien2361 22 күн бұрын
Loved your videos and animation! Mind sharing what software you used to make all these animations? (hope it's not just After Effects 😂)
@asoawrahman9218
@asoawrahman9218 21 күн бұрын
Great explanation, very understandable. A question: What software do you use for these animation, and illustration?
@bordercollie0115
@bordercollie0115 22 күн бұрын
I love theas vids so much i missed them ❤
@priyanshumaity6780
@priyanshumaity6780 22 күн бұрын
I know that you probably have answered this question quite a lot of times, but if you don't mind can you please tell me what software you use to create these animations?
@vastabyss6496
@vastabyss6496 22 күн бұрын
he probably uses PowerPoint like CoreDumped
@vastabyss6496
@vastabyss6496 22 күн бұрын
and I'm not joking when I say that
@priyanshumaity6780
@priyanshumaity6780 21 күн бұрын
@@vastabyss6496 When I think about it, it's not a bad idea. Thanks 🙏🏼
@chry003
@chry003 21 күн бұрын
Or, manim!?
@vastabyss6496
@vastabyss6496 21 күн бұрын
@@chry003 Manim and Motion Canvas are great, but I don't think that's what's being used here. If there was an algorithm being visualized that was doing tens or hundreds of operations, then using something like Manim would be best since it would be a pain to animate that all by hand. For this video though, it seems like animating it by hand wouldn't be too hard
@jshet
@jshet 21 күн бұрын
Was literally doing this chapter of Grokking Algorithms this morning.
@subinaypanda9936
@subinaypanda9936 13 күн бұрын
A few days before I have hard time to understand bellman ford algorithm. I like how you have explained two algorithms in just 13 minutes.
@dipeshsamrawat7957
@dipeshsamrawat7957 22 күн бұрын
Thank you 😊
@vader567
@vader567 22 күн бұрын
thats why i fkin love cs
@guilhermeduarte1932
@guilhermeduarte1932 22 күн бұрын
How do you know or find a way to determine the weight for each edge?
@moamab4541
@moamab4541 22 күн бұрын
Finally it's been a long time
@Jaiden-2013
@Jaiden-2013 12 күн бұрын
Is this true: the most battery path is Bellman ford algorithm but set the starting location to “max battery” - “current battery” and disallow vertices to be negative
@na50r24
@na50r24 4 күн бұрын
Question: Dijkstra should work for any graph as long there is no negative weight, no? Being a DAG is not a requirement for Dijkstra. Not sure if this is a weird question but Dijkstra is greedy but happens to work. Isn't there a non greedy Dynamic Programming approach to the shortest path problem? The reason for the second question: I think DAGs are graphs that can be actually solved with topological sorting and DP but I could be wrong.
@b001
@b001 4 күн бұрын
Correct, being a DAG is not a requirement for Dijkstra’s, nor is it a requirement for Bellman-Ford as long as the cycle isn’t negative and reachable by the source. I choose a DAG so that I could use the same graph throughout the video, so that once I created a negative weight edge, it ensured no negative weight cycle could exist so that the Bellman-Ford algorithm could solve it.
@fire17102
@fire17102 21 күн бұрын
A* in python next please ❤
@Milenakos
@Milenakos 22 күн бұрын
just bump all values by some amount such that the smallest negative becomes 0?
@asston712
@asston712 21 күн бұрын
that doesnt work. Say we have a graph with each edge bumped up by N distance. If we have a certain path that passes through 3 edges, the total bumped distance will be 3*N longer than the actual distance. However, consider a path that passes 5 edges, this path will have a total bumped distance 5*N longer than the actual distance. Bumping unfairly favors paths that travel over fewer edges. A concrete example is lets say we have 2 paths we can take: 1,1,1,1,1,1,1 or 20, -10 we know the top path is more efficient, but after bumping each distance by 10: 11,11,11,11,11,11,11 or 30,0 the bottom path becomes for efficient
@user-if1dj7fy2y
@user-if1dj7fy2y 22 күн бұрын
Salute 🙌 Bravo 👏👏 Lit 🌠 Impressive ❤ Gratitude 🥳✨ for your satisfactory Work 🚀🌟🌱
@potatofuryy
@potatofuryy 17 күн бұрын
A* My beloved
@KelvinWKiger
@KelvinWKiger 12 күн бұрын
bravo
@jobygejo3322
@jobygejo3322 22 күн бұрын
Finally you are back
@jamescollier3
@jamescollier3 22 күн бұрын
what about if some of these are highways
@Loaderdani
@Loaderdani 22 күн бұрын
Then the weight of those edges will be less, assuming that the computer is using time and not distance as its cost function.
@Loaderdani
@Loaderdani 22 күн бұрын
The algorithm doesn’t know the shape of the map, just the distance (in time) between intersections.
@PunamTish
@PunamTish 19 сағат бұрын
What's the meaning of your KZbin channel's name !
@b001
@b001 4 сағат бұрын
Originally, it was b001ean, using boolean values 0s and 1. It was later just shortened to b001 (pronounced “bool”)
@1.0
@1.0 22 күн бұрын
Duh, the shortest path is obviously a direct line between the points /j
@MuhammadAlotaibi1324
@MuhammadAlotaibi1324 20 күн бұрын
yet gives you the longest path
@iTz_Nao
@iTz_Nao 22 күн бұрын
first
@michaelt312
@michaelt312 22 күн бұрын
I'll take things that annoying to hear both on KZbin and in bed for $100.
Dijkstra's Hidden Prime Finding Algorithm
15:48
b001
Рет қаралды 160 М.
What Came Before The Big Bang?
1:01:23
History of the Universe
Рет қаралды 133 М.
A pack of chips with a surprise 🤣😍❤️ #demariki
00:14
Demariki
Рет қаралды 55 МЛН
The joker's house has been invaded by a pseudo-human#joker #shorts
00:39
Untitled Joker
Рет қаралды 11 МЛН
Жайдарман | Туған күн 2024 | Алматы
2:22:55
Jaidarman OFFICIAL / JCI
Рет қаралды 1,3 МЛН
THIS is Why List Comprehension is SO Efficient!
5:25
b001
Рет қаралды 170 М.
What School Didn't Tell You About Mazes #SoMEpi
12:49
mattbatwings
Рет қаралды 106 М.
5 Good Python Habits
17:35
Indently
Рет қаралды 399 М.
The hidden beauty of the A* algorithm
19:22
polylog
Рет қаралды 837 М.
The Algorithm Behind Spell Checkers
13:02
b001
Рет қаралды 405 М.
The Most Important Algorithm in Machine Learning
40:08
Artem Kirsanov
Рет қаралды 293 М.
Why Does Diffusion Work Better than Auto-Regression?
20:18
Algorithmic Simplicity
Рет қаралды 207 М.
Programming with Math | The Lambda Calculus
21:48
Eyesomorphic
Рет қаралды 114 М.
Dijkstra's Algorithm - Computerphile
10:43
Computerphile
Рет қаралды 1,3 МЛН
10 weird algorithms
9:06
Fireship
Рет қаралды 1,1 МЛН
A pack of chips with a surprise 🤣😍❤️ #demariki
00:14
Demariki
Рет қаралды 55 МЛН