Dijkstra's Algorithm vs Prim's Algorithm

  Рет қаралды 70,039

Back To Back SWE

Back To Back SWE

Күн бұрын

Пікірлер: 104
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
Table of Contents: Introduction 0:00 - 0:41 Tracing Optimal Solutions 0:41 - 1:26 Dijkstra: Walkthrough 1:26 - 13:42 Dijkstra: Visual 13:42 - 14:36 Prim: Walkthrough 14:36 - 19:23 Prim: Visual 19:23 - 19:48 Reviewing What We Learned 19:48 - 20:35
@inversemetric
@inversemetric 5 жыл бұрын
I heard that Dijkstra's algorithm does not always work well when the edges have negative weights. I considered if it would be possible to correct that by adding the absolute value of the most negative weight to every edge. It turns out that does not yield the correct answer unless you subtract that number * number of edges from the result for each path. This is probably common knowledge but seems fascinating to me.
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
@@inversemetric Yeah, I messed up in saying that, I went back to verify and dijkstra's only operates on graphs with positive edge weights, I made that comment on the spot with no diligence.
@Ruby-mr1gn
@Ruby-mr1gn 4 жыл бұрын
Dijkstra and Prim are used for dealing with different types of graphs and solving different kinds of problems: Dijkstra: Directed weighted(only allow non-negative weights) graph, find shortest lowest cost path from starting vertex to destination vertex; Prim: Undirected weighted graph, find lowest cost path to connect all vertices in this graph. Hope this helps ;)
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
yes
@priyamvashi2187
@priyamvashi2187 3 жыл бұрын
we can also apply Dijkstra to Undirected weighted
@ElfHimSelf
@ElfHimSelf 5 жыл бұрын
Got an offer from Lyft for the 2020 Software Engineering internship. Your videos helped me while studying 🙌
@imabeastyaok
@imabeastyaok 5 жыл бұрын
Toss me some money bro...those lyft salaries are crazyyy 😂🙏
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
Where's my 10k at? jkjk, yeah, my friend just did Lyft. 💩's wild. Happy things went well.
@Naradmaxwell
@Naradmaxwell 4 жыл бұрын
man, how did you make it?? please tell, it will really help me in getting an internship.
@aj-tg
@aj-tg 4 жыл бұрын
gg
@arrahul316
@arrahul316 4 жыл бұрын
The effort that you put at a very granular level is something truly commendable. This is the first time I understood both of these Alg and probably one of the the best 9 am to 10.30 am on a Sunday
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
great
@DJalyssagail
@DJalyssagail 4 жыл бұрын
i get excited when i search for an algorithms topic in youtube and your video appears. great explanation and teaching technique as always!
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
thx
@davidbellamy1388
@davidbellamy1388 4 жыл бұрын
I'm new here and don't know when you started, but you are underrated.
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
hahahahahaha, welcome to the 💩 show, please be seated
@cphash
@cphash 4 жыл бұрын
I specifically search for your videos whenever I want to understand the concepts. Thanks a lot for the content!
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
nice!
@sams7068
@sams7068 3 жыл бұрын
Great video, these are simple concepts but the way you tracked each node's parent in Dijkstra's Algorithm was a lifesaver. I was getting so bogged down in just maintaining my busy tree with arrows, etc. Saves a lot of confusion!
@BackToBackSWE
@BackToBackSWE 3 жыл бұрын
Glad you liked it
@thezanycosmophile
@thezanycosmophile 4 жыл бұрын
Appreciate what you’re doing so much! You have the right attitude for video, and your sincere efforts are visible to make us understand better. Thanks again.
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
ye
@rishabkumar4940
@rishabkumar4940 4 жыл бұрын
My friend was asked this question in an interview, he was very confused as the two algorithms do totally different jobs so how can they be compared. But now I understand that they are very similar. Thanks!
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
sure
@dab-city
@dab-city 5 жыл бұрын
this video just saved my gpa for real thank you thank you sir
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
Sure.
@qbertrtrtg
@qbertrtrtg 5 жыл бұрын
Just found your channel. I never liked learning about algorithms, time complexities... because it was too confusing and very dry (talking about that CLRS book.....) But the way you present content makes it very easy and interesting to learn about these topics now!
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
Nice! glad to hear
@galbalandroid
@galbalandroid 3 жыл бұрын
For the MST, why didn't we favor A->B->G? that would yield a cheaper overall tree than going through A->F->D->G?
@Dark1DICE
@Dark1DICE 11 ай бұрын
Very precise and clearly presented! Thanks!
@thecs490prof2
@thecs490prof2 4 жыл бұрын
Dude I love your lectures! I use them constantly to help prepare my own lectures for my Advanced Algorithms class :)
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
nice - hey
@thecs490prof2
@thecs490prof2 4 жыл бұрын
@@BackToBackSWE Btw if you're interested, I'd also be interested in a collab! I have a lot of students in my class, and I'd be happy if you wanted to do a guest lecture or make a small guest appearance :D It might be beneficial to you as well because some of my students might end up investing in your platform as well! Hit me up if you're interested - sr66+collab@njit.edu
@jayjin
@jayjin 5 жыл бұрын
Could you please make a video to explain Leetcode #4: Median of two sorted arrays. Thank you in advance!
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
yeah
@adriandeveraaa
@adriandeveraaa 5 жыл бұрын
I have yet to take an algos course. Transition from EE to CS. What is a "greedy" algorithm? And what video should I begin in your series D:?
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
brilliant.org/wiki/greedy-algorithm/ and not sure?
@neon_342
@neon_342 Жыл бұрын
Hello @backTobackswe. I love your lectures. After 6 months of doing research, I came to a solution that I need to purchase your course only. And I did it also. Can you please bring a series of lectures of DSA concepts. Not only solving questions. But what is what and how to create from scratch and its internal working in Java
@BackToBackSWE
@BackToBackSWE Жыл бұрын
Hi, thank you for your suggestions. Yes absolutely. We already have some videos explaining core DSA Concepts, you can find them here and on our platform - backtobackswe.com/ 😄
@neon_342
@neon_342 Жыл бұрын
@BaclToBackSWE are you going to add more questions on your platform ? Or remove some questions and in place of that adding new ones ? Are you going to add some OS, Networking, DBMS questions also in your package ? And how frequent you update your course content on your platform ?
@eashanmathur560
@eashanmathur560 4 жыл бұрын
In Prim's algorithm, why aren't nodes E and G connected? When you get to E, your only choice is to go to G so why wasn't that choice made?
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
I don't remember this video and dont have time to rewatch cuz replying fast
@eashanmathur2030
@eashanmathur2030 4 жыл бұрын
16:55
@annatvsf
@annatvsf 4 жыл бұрын
@@BackToBackSWE I also was wondering why we ignored EG edge and same situation with CF edge later. Is vertex supposed to have more than one edge to choose the min from?
@MiketheCoder
@MiketheCoder 5 жыл бұрын
Now the bigger question is in what scenario would you use one over the other?
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
wym
@join2nitin
@join2nitin 4 жыл бұрын
Can you please provide C# code implementation for problem "Find Shortest Path in undirected weighted graph from source vertex to each vertex", I have purchased your course but could not find code on your website.
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
Hey! We would love to, but right now we are rewriting everything from scratch and don't have too many resources to redirect (it is just 2 devs, us, right now). The new experience will be out in the middle of 2021.
@SunnyGuptaTech
@SunnyGuptaTech 4 жыл бұрын
Which microphone do you use to record your videos, the voice is crystal clear.
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
RODE VideoMic, the red one
@saravanprathi6956
@saravanprathi6956 4 жыл бұрын
Thanks a ton for this video, it really helped me!!
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
sure
@throwsand2
@throwsand2 3 жыл бұрын
you videos are super helpful, thanks so much!
@ilya1131
@ilya1131 3 жыл бұрын
didnt understood the culc of D, how is AD longer then AFD if the distance between AD is 7, and the distance between AFD is 5+7=12 (in the video its somehow 6)
@shantanutripathi
@shantanutripathi 4 жыл бұрын
Why no one is talking about what if cycle comes in while selecting the minimum edge and then we have to check for condition of cycle?
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
i like your profile pic
@shantanutripathi
@shantanutripathi 4 жыл бұрын
@@BackToBackSWE Tell the answer of the question or else I will come to you with 3 other friends of mine :)
@goodwish1543
@goodwish1543 5 жыл бұрын
Good idea to classify them. Thanks for teaching.
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
sure
@atulmalakar
@atulmalakar 5 жыл бұрын
Hey Ben this video was definitely very informative and nice like your other videos. However I have a request, can you please make a tutorial on maximum subarray sum using Divide and Conquer as there are not very good tutorials or blogs on the internet. I totally understand if you have different plans for your upcoming videos but this is just another fan request. Please give your suggestions.
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
ok
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
I think I have a video on that, max contiguous subarray sum
@atulmalakar
@atulmalakar 5 жыл бұрын
@@BackToBackSWE yes yes there is, but it is Kadane's algorithm and what I am asking for is Divide and Conquer solution. Thanks anyways !
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
@@atulmalakar ah, true, I may
@99ansh
@99ansh 4 жыл бұрын
Did anyone notice a bull shadow on the t-shirt? It's cool.
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
what lol
@TheKseth
@TheKseth 4 жыл бұрын
@@BackToBackSWE My man is a Dwayne Johnson fan
@parthokr
@parthokr 4 жыл бұрын
Can you make a video on bellman ford algorithm?
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
probably not it is niche and complicated
@jacekwzgorzeeliminujaczosl4036
@jacekwzgorzeeliminujaczosl4036 3 жыл бұрын
What happens when we stop developing people and reach our goals? We can all decide. But we can fight with disease and easily destroy it. We have the right to punish others, including children. How safe are all the medical centers in Spain? During the shortest period of human history, the Spanish Empire conquered Porto del Sur. "I only do nothing but shoes. I want to improve your life in Scotland and Spain. The king has been his friend for centuries, you can only serve the poor and the average. Often in the military. People say that chocolate and tobacco production Are successful. ".
@eugenemolokov3427
@eugenemolokov3427 5 жыл бұрын
Nice to see you back :)
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
hey
@ShaliniNegi24
@ShaliniNegi24 4 жыл бұрын
This guy is a Gem!
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
no ur a gem
@mohnishsinghbhamra
@mohnishsinghbhamra 3 жыл бұрын
you explained Prims MST in a kind of kruskal way
@supamdeepbains5172
@supamdeepbains5172 4 жыл бұрын
Dear Mr.Back to Back SWE, Hi there, I hope you're doing well, I just want to say that wonderful explanation as always on every video, but which one would you prefer to be used over another bro? Thanks Warm Regards,
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
Hi, preference for algorithms? not sure what you mean
@supamdeepbains5172
@supamdeepbains5172 4 жыл бұрын
@@BackToBackSWE Hi there , Yes bro for example which one is faster in order to use? Thanks Warm Regards,
@francescopiazza4882
@francescopiazza4882 11 ай бұрын
Very good, thanks !
@inigo1880
@inigo1880 3 жыл бұрын
MY DUDE IS RIPPED!
@Naradmaxwell
@Naradmaxwell 4 жыл бұрын
how do you find the LOWEST COST VERTEX ??
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
not sure
@NinoCuteCute
@NinoCuteCute 3 жыл бұрын
Nice,help me a lot
@ANGELINK999
@ANGELINK999 5 жыл бұрын
Awesome video!
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
thx
@ShubhamKumar-rt8nb
@ShubhamKumar-rt8nb 5 жыл бұрын
why do you not choose the edge from F to G it also has a weight of 6
@ShubhamKumar-rt8nb
@ShubhamKumar-rt8nb 5 жыл бұрын
@@iklilios thanks to clear it
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
nice
@soumadip_banerjee
@soumadip_banerjee 5 жыл бұрын
Love ur vids as usual!
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
yo
@silviapetrova8562
@silviapetrova8562 3 жыл бұрын
Thank you
@elleb6018
@elleb6018 3 жыл бұрын
Thank you ❤️
@taehyeonkim3900
@taehyeonkim3900 4 жыл бұрын
where is your emphasizing voice!?
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
wut
@JavaAidTutorials
@JavaAidTutorials 5 жыл бұрын
WAR between Dijkstra and Prims...:)
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
yes
@judgebot7353
@judgebot7353 Жыл бұрын
thanks
@prashanthvaidya
@prashanthvaidya 5 жыл бұрын
Great video. :) Especially Prim's algorithm and the "vision" bit was spot on. One caveat though! You mentioned going back could help if there was a negative edge, but Dijkstra's Algorithm fails to find a shortest path for a graph with negative weights. Once a vertex is taken out of the heap, it is assumed that the shortest possible path for that vertex has already been found.
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
Oh true, good point, I remember saying that and questioning if it was true
@TitanTubs
@TitanTubs 2 жыл бұрын
quality
3.5 Prims and Kruskals Algorithms - Greedy Method
20:12
Abdul Bari
Рет қаралды 2,9 МЛН
The hidden beauty of the A* algorithm
19:22
Polylog
Рет қаралды 898 М.
Players vs Pitch 🤯
00:26
LE FOOT EN VIDÉO
Рет қаралды 134 МЛН
The IMPOSSIBLE Puzzle..
00:55
Stokes Twins
Рет қаралды 170 МЛН
За кого болели?😂
00:18
МЯТНАЯ ФАНТА
Рет қаралды 3,1 МЛН
Dijkstra's Algorithm - Computerphile
10:43
Computerphile
Рет қаралды 1,3 МЛН
Interval Scheduling Maximization (Proof w/ Exchange Argument)
20:20
Back To Back SWE
Рет қаралды 65 М.
11. Dynamic Programming: All-Pairs Shortest Paths
1:21:49
MIT OpenCourseWare
Рет қаралды 108 М.
How Dijkstra's Algorithm Works
8:31
Spanning Tree
Рет қаралды 1,4 МЛН
Network Flows: Max-Flow Min-Cut Theorem (& Ford-Fulkerson Algorithm)
21:56
Professor Clyde Kruskal On Kruskal's Algorithm
6:15
Back To Back SWE
Рет қаралды 40 М.
3.6 Dijkstra Algorithm - Single Source Shortest Path - Greedy Method
18:35
12. Greedy Algorithms: Minimum Spanning Tree
1:22:10
MIT OpenCourseWare
Рет қаралды 228 М.
Prim's Minimum Spanning Tree Algorithm | Graph Theory
14:53
WilliamFiset
Рет қаралды 124 М.
Players vs Pitch 🤯
00:26
LE FOOT EN VIDÉO
Рет қаралды 134 МЛН