Prim's Algorithm - Graphs | Minimum Spanning Tree(MST) in Graphs | Code and Implementation
Вставка
- Опубліковано 11 жов 2024
- Please consume this content on nados.pepcoding.com for a richer experience. It is necessary to solve the questions while watching videos, nados.pepcoding.com enables that.
NADOS also enables doubt support, career opportunities and contests besides free of charge content for learning. In this video, we explain the Prim's algorithms used to find the minimum spanning tree in a graph. We also explain about spanning trees in graphs followed by the implementation and code of this algorithm in a problem where:
1. You are given a graph and a source vertex. The vertices represent computers and the edges represent length of LAN wire required to connect them.
2. You are required to find the minimum length of wire required to connect all PCs over a network. Print the output in terms of which all PCs need to be connected, and the length of wire between them.
For output, check the video.
For a better experience and more exercises, VISIT: www.pepcoding....
#graphs #prims #spanningtree
Have a look at our result: www.pepcoding....
Follow us on our FB page: / pepcoding
Follow us on Instagram: / pepcoding
Follow us on LinkedIn: / pepcoding-education
Join us on Telegram: t.me/joinchat/...
@ 9:14, He is such a awesome teacher agar ye chahte toh bolskte the ki video rewind Krke fir se dekhlo but he did the same dryRun again ❤️.
Respect ++🙏
I was not able to understand why we used Prims instead of Dijkstra, but at @ 16:48 he told to find difference in answers if graph was different and when I did it the confusion went away, he is by far the best teacher for learning DSA that too FREE. Hats off to you sir.
if someone still confused in difference between dijkstra and prim. In prim you have to cover all the vertices but in dijkstra its not necessary. Solve the last graph with 25 weight sir gave it will be cleared.
This is the best video on youtube for prims, really thrilled on knowing
wow, this cheers me up. I am glad we at pepcoding could be of help to you. Keep learning. Also, recommend us to your juniors and peers, they may also benefit.
Best Explanation of prims ever found on you tube!!
Glad it was helpful. Keep learning, Keep growing and keep loving Pepcoding!😊
sir please upload advance graph playlist also i have completed the whole playlist and i just love your teaching.
Let's do some practice together ,share good questions with me on my whatsapp haha😂😂😂😂
Which language do you prefer ?
Java.
Are bhai bhai bhai bhai!!!!!!!!!!!!!!!!!!!!!!! . Sir you are Legend in the field of DS Algo. You can make any algorithm simple , and also you are the USP of pepcoding , so I would request you to continue making DS videos.
Thank you for appreciating.
The love and respect which I get from you people keep me highly motivated and the same I am able to forward It to you people through my videos.
So, keep motivating, keep learning and keep loving Pepcoding😊
With Prim's algorithm we find minimum cost spanning tree. The goal is to find minimum cost to cover all nodes.
with Dijkstra we find Single Source Shortest Path. The goal is find the shortest path from the source to every other node
Have seen other videos too of the same concept.... but so far this is the best explanation of this problem.. 👍👍
best explanation available on youtube
Difference in the answer if we consider the question given at 17:05
Dijkstra- reaching 6 would take 0346 or 03456
Prims- reaching 6 would take 0123456
Great content sir🙏. Typo in the thumbnail of this one.
Thank you crystal explaination
Thanks, ..very simple approach used compare to other solutions available on yt
Beautifully explained !
Such a simple and amazing implementation of prims. This is what i had in my mind but thought i was wrong because everyone was using 3 vector for some reason. Thanks thank you again.
Bhot badiya vedio ..your channel will be so successful. The way you teach is simply awsome
Glad you liked it!
For better experience, visit nados.io, where you will get well curated content and career opportunities.
Very Nicely Explained!
Glad it was helpful! For more content like this please visit nados.pepcoding.com
That was too awesome! Thanks for the content sir
Sir you are awesome
And your way of teaching is feel like i am listening this in front of you 🔥
Thankyou beta!
I am glad you liked it. I hope that you are watching till the end and trying to understand what, how, and especially why of the problem.
If you like our efforts, will you like to write a few words about us here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )
Please cover flyod warshall also.
Great Explanation. Thank you sir
Bhaiya, can you upload more graph related algorithms like Kruskal's and Bellman Ford's.. etc.?
Amazing video
Sir pelease make more videos on algorithms and data structures asked in Mnc interviews🙏🙏
Why does it give TLE on gfg even though if we are doing a BFS,
I GUESS we are marking visited while popping instead of pushing ,
Are we doing a lot of extra work in rm*wa*?
SIr! If the vtces (4--6) had a weight of 5 then for minimum spanning (4-6) vtces should have been selected but from this code it wont be selected.
It will still take the (4-5) and (5-6) path
4-6 does not include vertex 5. That's why
Check your code for Dijkstra's it will work fine but here in prims it checks for the minimum edge weight by not taking previous weights for comparison, so in this question, the shortest distance to 6 will be comparing it with the min(5--6, 4--6) which will be 5--6.
@Pepcoding Graphs ki bhi porri playlist daal do youtube pe. Itna kar diya toh thoda or, please
Sir please upload dynamic programming adv wale ques , final year walo Ka bhala ho jayega
beta foundation ke graphs ka last video bna rha hun. aj he levelup shuru hoga.
@@Pepcoding Sir graphs k level up k vidoes ka link kahan hai?
Sir, Can you please tell us what is the time complexity of this prim's algorithm code?
MST without source, then we'll traverse from 0 to n-11 nodes. In gfg it's showing TLE. Sir please upload optimized way of prim's
sir please kruskals pe bhi video banao
Sir MySQL and SQL ke lecture suggest kar dijiye jo apki tarah padata ho.
Thank you so much sir
I am glad you liked it. I also hope that you are watching till end and trying to understand the what, how and especially why of the problem.
If you like my efforts, I request a review
g.page/Pepcoding/review?rc
@@Pepcoding already done sr
maza aa gaui
Thankyou beta!
I am glad you liked it. I hope that you are watching till the end and trying to understand what, how, and especially why of the problem.
If you like our efforts, will you like to write a few words about us here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )
Please cover "circle of strings" on geeksforgeeks
Ok
@@Pepcoding waiting
Sir, Bellman Ford or Kruskal's jaroori hain?
hanji jaroori hai
hi sir
isko 2D matrix me input leka sove karna hua toh kaise karnege ...jaisa input leetcode aur gfg pe diya hua hai
usko adjacency list me convert karo
Hi Sumit, please do make video on Kruskal's Algo. Already made video is really poor. Please help
Feedback taken, for better experience and well organised content sign up on nados.io and start learning.
saare topics miljate hain is channel par :)
Thank you so much and If you like the content could you post something on LinkedIn about us? This will help us in reaching out to more people and help a lot of other students as well
Something like this
Sumeet Malik from Pepcoding is making all his content freely available to the community
You can check it out here - www.pepcoding.com/resources
/
Also, this is the youtube channel - ua-cam.com/users/Pepcodingplaylists?view_as=subscriber
To get placement kis hisab sa mujha serial vise video dekhni chahiya .I have no knowledge about it .pls guide me I have passed class 12.
This is the proper to do these questions
www.pepcoding.com/resources/online-java-foundation
Thnk you sir
time complexity kyu nai samjai sir :(((
I have two doubts
1) what is the time complexity of this algo?
2) which is better, prims or kruskal?
i think complexity is same as that of dijkstra elogv
1.Time -O(vertices + edges)
Space - O(vertices)
Sir kruskal pe bhi question kara dijie
level2 mei
koi sir ki videos ke notes bna rha hai kya? agar haa toh please reply
can you provide a C++ code for this ?
Basically primes is more greedy.
this concept is not applicable on some other question
we are not able to solve other question using this concept
Anayatha 🙂
Visit - nados.pepcoding.com and sign up to NADOS.
Don't forget to follow us on Instagram instagram.com/pepcoding/
Sir Kruskals algo ki video kidhar hai ?
beta foundation prims pe khatam kar dia. Level2 ke graphs mei daalunga kruskals. Wo thoda padhane mei samjhane mei jyada time leti hai
@@Pepcoding Sir thode aur acche questions daaliye,bhut shi pd rhe ho aap,mze aa jaate he,aur bilkul bhi bhulne nhi dete aap phle ka,bhut baar revise kra dete ho. Thanks for all this.