G-45. Prim's Algorithm - Minimum Spanning Tree - C++ and Java

  Рет қаралды 271,300

take U forward

take U forward

Күн бұрын

Пікірлер: 629
@takeUforward
@takeUforward 2 жыл бұрын
Let's continue the habit of commenting “understood” if you got the entire video. Please give it a like too, you don't 😞 Do follow me on Instagram: striver_79
@ujjawal_
@ujjawal_ 2 жыл бұрын
thanks for your valuable content 🙂
@rishav144
@rishav144 2 жыл бұрын
understood ♨️
@youtubegaming7791
@youtubegaming7791 2 жыл бұрын
bhaiya notes link
@dr.stereo_4046
@dr.stereo_4046 2 жыл бұрын
Oh ho maje aa gye tree me to 😁. Thanks bhaiya
@dr.stereo_4046
@dr.stereo_4046 2 жыл бұрын
Understood understood understood 😊
@ary_21
@ary_21 Жыл бұрын
Notes for self! Required data structures 1. Min heap 2. Visited array 3. Mst list that will store all the edges that are a part of MST Datatypes of our data structures Visited array => int Mst list => (weight , node name , node parent) Steps 1. Mark the visited array as 0 for all the nodes 2. Start with 0th node and push (0,0,-1) explanation: -1 means 0 is the genesis node Mark 0 as visited 3. Push all the neighbours of 0 in pq *Do not mark them visited* (footnote 1) Since its a min heap the edge with minimum weight will be at the top 4. Pick up the top edge , insert it in the mst , mark the picked node as visited , insert all neighbours of picked node into pq 5. keep repeating steps 3 and 4 untill all the nodes have been picked up and thats when the algorithm ends footnote: 1. why to not mark it visited? in bfs , when we push the element inside a queue we mark it as visited cause that element will be picked up later for sure (algorithm ends only when the queue is empty ) but in msts case even if we push the edge into pq , theres no surety that the edge will be picked up . when prims algo ends there are still a few non accepted edges present in the pq hence we only mark it visited once its picked up from pq
@RANGER_Rajat
@RANGER_Rajat 10 ай бұрын
👍
@ayushanand5659
@ayushanand5659 10 ай бұрын
Copy mein bana leta bhai
@IshaanJoshi-ms9mb
@IshaanJoshi-ms9mb 6 ай бұрын
@@ayushanand5659 lol
@valendradangi1822
@valendradangi1822 5 ай бұрын
I think 0 is not marked visited while pushing into the queue but when it is taken out of queue
@43johri
@43johri Ай бұрын
In BFS also, you can do same thing. First add it to the queue, and once popped, mark it visited and continue. What do you think is wrong with this approach ?
@ayushpatel2171
@ayushpatel2171 2 жыл бұрын
All the newbies just wait for some time. When you will feel like banging your head due to dynamic programming problems, this channel will save you. He doesn't need any controversy to grow his channel. He is making videos to make quality content available on youtube for free. His audience may be small but it is loyal. And when it comes to studying you only get this many view. Bcoz that is the real number of serious students.
@shivanshnamdev6417
@shivanshnamdev6417 2 жыл бұрын
😹 lol having 3 lakh subs And Views 5-10 k I think paid Views Hain 😹😹😹
@ayushpatel2171
@ayushpatel2171 2 жыл бұрын
@@shivanshnamdev6417 Advanced topic itne hi log padhte hai. Waki log bas c aur java ka one shot hi deakh te rehte hai.
@shivanshnamdev6417
@shivanshnamdev6417 2 жыл бұрын
😹 Baas Karo yaar Itna Kon defend karta Hai chalo maan Liya Aap sahi per itne hi agrr advance padhte toh 10-15 k subs baas hone the baaki kya churake laaye
@atheisttttt
@atheisttttt 2 жыл бұрын
@@ayushpatel2171 💀
@atheisttttt
@atheisttttt 2 жыл бұрын
@@shivanshnamdev6417 4 saal baad ana
@WhyYouN00B
@WhyYouN00B 2 жыл бұрын
Striver bhaiya ignore these freshers Bache hai samaj utna hai nhi U just keep moving forward Love you 100000❤❤❤❤
@bibaswanmukherjee6853
@bibaswanmukherjee6853 2 жыл бұрын
Those who are coming here to criticize striver you don't know the struggle he did to get to the place where he is now and also his quality of teaching is top notch. His DP series is pure gold
@pritammehta7770
@pritammehta7770 2 жыл бұрын
But what he said was right ?
@vaibhavnayak233
@vaibhavnayak233 2 жыл бұрын
@@pritammehta7770yeah. Maybe using a girl thumb line was wrong point but rest of the part is 100% right.
@JohnWick-oj6bw
@JohnWick-oj6bw 2 жыл бұрын
@@vaibhavnayak233 He was 100% right about that too. See, how she played victim card when faced with criticism. And all the toxic ppl coming to defend her??? Only cuz she's a female
@anshumaan1024
@anshumaan1024 Жыл бұрын
@@JohnWick-oj6bw kon critcise kr rha tha bhai ?🙄
@Moch117
@Moch117 Жыл бұрын
Who is criticizing him and for what ? @@pritammehta7770
@nishantbhardwaj9757
@nishantbhardwaj9757 Жыл бұрын
I didnt even know about how to calculate sum in an array around 6-7 months ago but now i had solved over 400 questions, Thank you so much for making this possible .
@pratiknagdeve3259
@pratiknagdeve3259 2 жыл бұрын
I know lots of ignorant will come to hate you but after they know you very well they will come back to you to learn from you regarding competitive coding and DSA.
@peterfromengland8663
@peterfromengland8663 2 жыл бұрын
Whoever criticizing striver you will know the quality of this man ,when you really start coding from heart
@Moch117
@Moch117 Жыл бұрын
Who is criticizing him and for what ?
@harshal_bh
@harshal_bh 2 жыл бұрын
as a working professional, I find ur videos are the best and in-line with important and freq asked dsa questions, completed dp playlist already, do not pay heed to these guys and carry on
@truthquest4404
@truthquest4404 2 жыл бұрын
Striver is real teacher. And motivation for me 3million ka channel ek tweet ka reply karne ke liye video bana pada😂😂
@MN-gn7lt
@MN-gn7lt 2 жыл бұрын
Ye daar hona jaruri hai❤😂💯
@user-fz1yv4lq4d
@user-fz1yv4lq4d 2 жыл бұрын
@@MN-gn7lt tere behen ko koi Bolega na tab mat bolna
@Rajat_maurya
@Rajat_maurya 2 жыл бұрын
ye dar hame accha laga
@JustForFun-zz2hb
@JustForFun-zz2hb 2 жыл бұрын
At 8:45 , node 2 is already visited so it should not be added to the priority queue. However it does not make any difference as node 2 is already visited and will not make any changes to our answer.
@takeUforward
@takeUforward 2 жыл бұрын
OOps sorry, yes
@jadejaharshvardhansinh8332
@jadejaharshvardhansinh8332 2 жыл бұрын
Yeah I watched it Second time and then noticed it😅 good point!
@Saurabh-fe2bg
@Saurabh-fe2bg Жыл бұрын
Paused the vdo...and searched for the comment which mentioned this
@praneethkonduru9000
@praneethkonduru9000 Жыл бұрын
nice one i also observed this
@gigglezone3432
@gigglezone3432 Жыл бұрын
Yea I was searching for this comment, why nobody pointed out the error. Got it!!
@aniruddhadas1778
@aniruddhadas1778 2 жыл бұрын
When you are starting your journey in DSA then you would grab those dhattarwal videos but as time elapses you will understand the worth of this man STRIVER❤️
@study8
@study8 2 жыл бұрын
Should i learn Java aur c++ for this
@pradeepkumarbishnoi8127
@pradeepkumarbishnoi8127 2 жыл бұрын
Dehk bhai tuje iska acha lag ta hai tu iska dehk. Muje jo jada samj ayaga ma uska dehkuga. To isma nahi hi tu galat hai or na hi main.
@JohnWick-oj6bw
@JohnWick-oj6bw 2 жыл бұрын
@@study8 C++ is better for this
@visase2036
@visase2036 2 жыл бұрын
Thanks once Again Striver, For Freshers, this is great . But I feel that Prim's video in your old Graph playlist was more intuitional and crystal clear.
@takeUforward
@takeUforward 2 жыл бұрын
But it was a bit complex, this is more straightforward and easy 😅
@pulkitagrawal8046
@pulkitagrawal8046 Жыл бұрын
I too felt in the same way
@shashankjoshi8250
@shashankjoshi8250 7 ай бұрын
Really good Explanation - Just one feedback, start with Intuition first then move forward with the algorithm instead of other way around.
@AashiSaxena-g8z
@AashiSaxena-g8z 6 ай бұрын
Best thing about him is that he emphasises on what we should not do. That's the way we remember it oo
@Subhamoygpt
@Subhamoygpt Жыл бұрын
Again a master piece. Thanks for this video striver. I think the last (2,2,3) should not be added as 2 is already visited when we are standing at 3.
@arpitrajput6424
@arpitrajput6424 Жыл бұрын
Code according to explanation C++ int spanningTree(int V, vector adj[]) { // code here vector vis(V,0); vector mst; priority_queue pq; pq.push({0,{0,-1}}); int sum=0; while(pq.size()){ int dis = pq.top().first; int node = pq.top().second.first; int parent = pq.top().second.second; pq.pop(); if(vis[node])continue; if(parent!= -1) mst.push_back({node,parent}); vis[node] = 1; sum += dis; for(auto it : adj[node]){ int adjNode = it[0]; int edgeW = it[1]; if(!vis[adjNode]){ pq.push({edgeW,{adjNode,node}}); } } } // printing mst // for(auto it : mst){ // cout
@avocode1487
@avocode1487 2 жыл бұрын
waiting for new videos bhaiyya, and I really want to thank you, bcoz of your awesome and crystal clear lectures, I completed graphs like topic in just a week, all credit goes to you, thank u so much bhaiyya. 👍
@meetkgp
@meetkgp Жыл бұрын
I really enjoy watching your videos! I have two pieces of constructive feedback that I hope will be helpful: 1. [Addressed] Already pointed out by Just For Fun: At 8:37, node 2 is already visited, so it should not be added to the priority queue 2. At 16:20, during your explanation of the intuition, you covered Kruskal's MST instead of Prim's MST
@shreyanshagrawal3115
@shreyanshagrawal3115 Жыл бұрын
what should be Prim's then?
@lakshsinghania
@lakshsinghania Жыл бұрын
@@shreyanshagrawal3115 exactly!
@shivamnegi7552
@shivamnegi7552 Жыл бұрын
no bro , both prim's kruskal are greedy , intuition for both are same we doing greedy in both cases .
@bulioh
@bulioh 8 ай бұрын
Yeah I was confused at 16:24 since I don't think that edge (1,4,3) would be in the priority queue yet
@nishant1456
@nishant1456 2 жыл бұрын
CP is incomplete without this guy
@preranapatro2414
@preranapatro2414 Жыл бұрын
U r the best ...no other content can ever be better then this one ..🥰🥰🥰🥰🥰🥰💌
@harshprit_k
@harshprit_k 2 жыл бұрын
Abhi Aman Aman kar rhe h sabhi, 3 saal ke baad yahi se placement k liye padhenge 😂
@vegitokun
@vegitokun 2 жыл бұрын
Bhai m 11th class m hun, iss bande ka content shi m achcha h kya? Abhi jee ki prep kar raha hun.
@harshprit_k
@harshprit_k 2 жыл бұрын
@@vegitokun yes bro, content is damn good, having opinion about something shouldn't affect your decision. Or just wait for 3 years, you will automatically know why i am saying this..
@Rajat_maurya
@Rajat_maurya 2 жыл бұрын
ekdam sahi bat bole bhai...abhi fresher hai inko kya hi pata job lena kitta mushkil hai
@amanasrani6405
@amanasrani6405 5 ай бұрын
Thank You Striver, If you are not there pata nhi kya hota thousand of student ka Amazingggggg! also hats off to your patience doing dry run❤❤❤❤❤❤❤
@neilbohr6015
@neilbohr6015 8 ай бұрын
in the worst case scenario wouldn't TC be V(logV+V-1+logV) for each vertex we are travelling all its edges(which can be at max v-1 in complete graph for a vertex ) 🤔🤔 just thinking
@nishantbhardwaj9757
@nishantbhardwaj9757 Жыл бұрын
Your data structures and algorithms playlist is amazing sir tbh i had watched all your playlist and again tbh i had watched babbar bhaiyaa’s also , both of you are amazing no hate to anyone , just keep the good work going .
@codingkrtehum..
@codingkrtehum.. 13 күн бұрын
understood, really nice way of explanation . i got it in one shot.👍
@lonerider6695
@lonerider6695 4 ай бұрын
basically pq is ensuring that we get min distance from source to each node and vis array is making sure all that all nodes are visited And carefully observing these two are the only conditions for a MST i.e. min dis (done by pq) and all node are connected (vis array taking care of that)
@AtharvaRao0104
@AtharvaRao0104 2 ай бұрын
PQ will only have crossing edges. and it gives the min weight edge when asked ..this will ultimately ensure you build a MST .. visited array is to keep the vertices already in the MST. And at the end, all vertices have to be in the MST. (and V-1 Edges also will be in MST.)
@keepitup3077
@keepitup3077 2 жыл бұрын
Driver bhaiya aapke to maje hai yaar😁😁😁
@saibunny1253
@saibunny1253 7 ай бұрын
striver bhai today i understood prim's algorithm using ds priority queue to find minimum spanning tree thank you
@funnyanimation888
@funnyanimation888 Жыл бұрын
It cleared almost all of the dought and got a very good intution .
@dhruvsolanki4473
@dhruvsolanki4473 6 ай бұрын
Amazing explanation, thank you for teaching us.
@rishav144
@rishav144 2 жыл бұрын
thanks Striver for great playlist
@shigoeditz7079
@shigoeditz7079 11 ай бұрын
Thankyou Striver for such a beautiful explanation ❤ and a Happy New Year ❤🎉
@h108pranavshinde3
@h108pranavshinde3 6 ай бұрын
God bless you bro ! You are taking too much effort to teach. This shows your dedication and passion 🔥🔥✨✨
@raghavagrawal9240
@raghavagrawal9240 2 жыл бұрын
Waiting for the next videos of this series!
@stith_pragya
@stith_pragya 11 ай бұрын
Thank You So Much for this wonderful video............🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
@bhadanavikas_13
@bhadanavikas_13 2 жыл бұрын
Why people commenting so much toxicity about him what's his fault ? He's right 💯 in very instances, firstly, for all who comments toxicity about him ( like driver bahiya etc ), first of all read his all tweets and information that he point about apna college team deeply , You (students ) are Aman dhatarwal fan is not the reason ki tum uski koi buri cheez ko point out nhi kroge . Same on you 😳😳😳
@MN-gn7lt
@MN-gn7lt 2 жыл бұрын
Guys twitter pe jo accha kaam kiya hai striver ne woh daalo unko bhi toh pata chale ki ye jiska course shikhate hai ye bhandha uss chez ka GOD hai😎
@user-fz1yv4lq4d
@user-fz1yv4lq4d 2 жыл бұрын
Teri behen ko koi ese hi bolega to tujhe chalega kya
@user-fz1yv4lq4d
@user-fz1yv4lq4d 2 жыл бұрын
People are toxic because of his thoughts are toxic
@MN-gn7lt
@MN-gn7lt 2 жыл бұрын
@@user-fz1yv4lq4d haan chal abhi apne kaksha meh ja ke bheth ja
@user-fz1yv4lq4d
@user-fz1yv4lq4d 2 жыл бұрын
@@MN-gn7lt ab Jada ro mt
@simmi641
@simmi641 Жыл бұрын
Striver=huge love+respect❤
@VIVardhan5130
@VIVardhan5130 Жыл бұрын
You are still more than god for some people striver
@krishanpratap3286
@krishanpratap3286 2 жыл бұрын
Maja aa gaya bhayiya love your content
@harshjoshi5888
@harshjoshi5888 2 жыл бұрын
Hello bhai want to tell you something serious .yeh jo aapke channel mein comments ho rhe hain unpe bilkul dhyan math Dena they are not college students they are so called jee neet aspirants who don't want to study for themselves but want themselves to be a saviour of their so called teachers .they are toxic fans of their teachers who don't want their students to think practically but let them to think only emotionally . Leave them aside we were with you and always . Please pin my comment because this is really serious
@JohnWick-oj6bw
@JohnWick-oj6bw 2 жыл бұрын
Most of them are arts student man
@harshjoshi5888
@harshjoshi5888 2 жыл бұрын
@@JohnWick-oj6bw not arts students bro they science students only and call themselves an aspirant yeh log poore saal bhaiya didi hi karte rehte hain main isliye yeh sab kh paa rha hoo kyuki do saal pehle main jis institute mein tha in online for jee coaching yeh sab vha aake teachers ko galiyan dete the ki tumhari toh fees itni jyada h vgrh
@harshjoshi5888
@harshjoshi5888 2 жыл бұрын
@@JohnWick-oj6bw believe me I have an experience about who is fooling us and who is giving an authentic education .
@sarangs722
@sarangs722 2 жыл бұрын
Apna College's content isn't that good. So, now they have resorted to attacking with playing the petty "women victim card". Striver, we love you bro. Your content is clearly better than that channel's content. Keep going! We are here with you.
@JohnWick-oj6bw
@JohnWick-oj6bw 2 жыл бұрын
They know, all the nalla berozgar are feminists. And will spread toxicity, so he xan continue fooling students.
@udaytewary3809
@udaytewary3809 Жыл бұрын
Understood bhaiya 🙏❤️
@abhishekudiya8638
@abhishekudiya8638 2 жыл бұрын
Firstly Striver your content is awesome and this graph series is top-notch ..can you tell us this series is completed or if more videos will be come in the future in this graph series and when will be new videos coming .
@cinime
@cinime 2 жыл бұрын
Understood! Super awesome explanation as always, thank you very much!!
@UECAshutoshKumar
@UECAshutoshKumar 11 ай бұрын
Thank you sir 😊
@sukhpreetsingh5200
@sukhpreetsingh5200 Жыл бұрын
Understood and awesome as usual
@varunakrishnani7688
@varunakrishnani7688 Жыл бұрын
Understood! :) Thank you bhaiya! 🙏🏻😊
@Rajat_maurya
@Rajat_maurya 2 жыл бұрын
Please make video on union find (DSU) questions... not able to solve leetcode ones
@tanishkumar5440
@tanishkumar5440 2 жыл бұрын
Mil gya fame , driver bhaiya appko . 😅
@amitp277
@amitp277 Жыл бұрын
Awesome 👏👏 this one is similar to Dijkstra's
@CodeMode9313
@CodeMode9313 Жыл бұрын
Habibi ek aur mast bideo banaye ho
@gauravlokwani8623
@gauravlokwani8623 2 жыл бұрын
Thank you so much for this video, could please also make the video on kruskal algorithm for this new playlist..??
@takeUforward
@takeUforward 2 жыл бұрын
Yes it will come soon.
@euvsielr
@euvsielr 2 жыл бұрын
I completely agree with you bhaiya.
@vaalarivan_p
@vaalarivan_p Жыл бұрын
2:10 - 6:57
@Stellar_7x
@Stellar_7x 2 ай бұрын
UNDERSTOOD!!
@ARNAVGUPTA-s1m
@ARNAVGUPTA-s1m 2 ай бұрын
In the end, while explaining the intuition for the Algorithm, you gave the explanation for the Kruskal's algorithm by mistake. The Prim's Algorithm works on the fact that we try to add unvisited nodes to our MST, but we search for the new nodes through a greedy approach of looking at the minimum weighted edges first. Actually, the difference between the Algorithms is very subtle. For Kruskals: we look at smallest edges, and then check if it is a new node. Prim's: we are increasing our MST by adding new nodes, by looking at the smallest edge option from the nodes we already have visited.
@mriduljain6809
@mriduljain6809 Жыл бұрын
Understood Bhaiya
@hrushi_borhade
@hrushi_borhade Жыл бұрын
Understood Striver!!
@hardikjain-brb
@hardikjain-brb 11 ай бұрын
Lol the intuition was mix of prims and kruskal>! Prims would be 0-1 2-1 (2-4 or 2-3) then 4-3
@gangsta_coder_12
@gangsta_coder_12 Жыл бұрын
Understood 🔥🔥
@shauryatomer1058
@shauryatomer1058 3 ай бұрын
thanks for the great video
@aayushojha3088
@aayushojha3088 Жыл бұрын
I think the adj nodes wala loop ,will run for 2E , ans no of adjnodes or neighbours in undirected graph is 2E
@parshchoradia9909
@parshchoradia9909 Жыл бұрын
Understood Sir!
@Learnprogramming-q7f
@Learnprogramming-q7f 6 ай бұрын
Thank you bhaiya
@aniruddhadas1778
@aniruddhadas1778 2 жыл бұрын
@8:44 node 2 should not be included in the priority queue as node 2 was already visited
@abhijeetmishra3804
@abhijeetmishra3804 Жыл бұрын
understood bhaiya
@matmister1769
@matmister1769 11 ай бұрын
vector adj[] Can anyone explain to me how this data structure is working? it is an array of vectors of vectors. Not sure why a 3 level dagta structure is needed.
@mihirsaini592
@mihirsaini592 2 жыл бұрын
Thank you striver
@PriyaGupta-sg4sm
@PriyaGupta-sg4sm 9 ай бұрын
Why did we take (2,2,3) at 8:45, we see before added if the node is already visited no? pls clarify
@priyanshgarg1292
@priyanshgarg1292 4 ай бұрын
shouldn't be added mistake
@amanbhagat1616
@amanbhagat1616 5 ай бұрын
I think time complexity is - E(log E + E Log E) =~ E^2 Log E ? [1]Outer while loop running E times at max (as explained in video) [2] Inside while pop from Heap (or Priority Queue) would take up Log E (as explained in video) [3] Iterating over neighbors and adding them to Priority Queue taking E log E (as explained in video) So, overall time complexity should be E^2 Log E ? isn't it? does anyone thinks the same?
@utkarshiitbhu4204
@utkarshiitbhu4204 4 ай бұрын
thats what i m thinking
@itz_me_imraan02
@itz_me_imraan02 Жыл бұрын
Perfect as always ♥
@ACUCSPRADEEPB-up9ne
@ACUCSPRADEEPB-up9ne Жыл бұрын
Understood✌️
@infinite9953
@infinite9953 2 жыл бұрын
Understood 🙌
@adebisisheriff159
@adebisisheriff159 10 ай бұрын
Thanks striver!!!!
@surjendupal7576
@surjendupal7576 2 жыл бұрын
Sir asking off topic question....... What's your tech stack? Means which technology you are proficient?
@just.subhan.
@just.subhan. 2 жыл бұрын
Haa bhaiyyy DRIVER OP😂😂. Be prepared bro. Now your channel will grow ultimately. After apna cllg. Video.what a Smart move😂😂😂.
@JohnWick-oj6bw
@JohnWick-oj6bw 2 жыл бұрын
Congrats, u helped him grow even more. 🤣 He doesn't need thumbnail waali ldki now 😂
@jaishriharivishnu
@jaishriharivishnu 5 ай бұрын
int spanningTree(int V, vector adj[]) { // distance, node, parent priority_queuepq; // initially take node 0 vectorvis(V); vis[0]=1; for(auto K:adj[0]){ pq.push({K[1],K[0],0}); } vectoredges; // weight, node , node // edges are the edges that will be in the MST while(!pq.empty()){ auto cur=pq.top(); pq.pop(); int curnode=cur[1]; int parent=cur[2]; int curdistance=cur[0]; if(!vis[curnode]){ vis[curnode]=1; edges.push_back(cur); for(auto K:adj[curnode]){ int childnode=K[0]; int childdistance=K[1]; if(!vis[childnode]){ pq.push({K[1],childnode,curnode}); } } } } int answer=0; for(auto K:edges){ answer+=K[0]; } return answer; } code for GFG.... NOTE: this also include the all the edges of the MST :)
@prakashnandan7337
@prakashnandan7337 Жыл бұрын
At 8:55 as 2 is already visited, (2,2,3) must not push into the pq
@dharmenderkumar2841
@dharmenderkumar2841 Жыл бұрын
UNDERSTOOD
@ShivamYadav-xx6oc
@ShivamYadav-xx6oc 2 жыл бұрын
lage raho driver bhai😂😂
@sandeepsuman6381
@sandeepsuman6381 2 жыл бұрын
Has le , abhi baccha hai 2-3 saal baad yahi se padhega
@navneetsingh2274
@navneetsingh2274 2 жыл бұрын
@@sandeepsuman6381 naa bhaiii humm too apna college se pdenge
@justarandomguy6106
@justarandomguy6106 Жыл бұрын
@@navneetsingh2274 mujhe controversy ka to pta nhi kya hua , lekin apna college ka content comparable bhi nahi hai abhi striver se
@amanbhadani8840
@amanbhadani8840 2 жыл бұрын
This time prims algorithm is little easy and not complex than from previous graph series.
@2amCoder
@2amCoder 10 ай бұрын
for java folks who is facing problem ArrayList adjList = new ArrayList(); for (int i = 0; i < V; i++) { adjList.add(new ArrayList()); } for (int i = 0; i < E; i++) { int u = edges[i][0]; int v = edges[i][1]; int weight = edges[i][2]; adjList.get(u).add(new Pair(weight, v)); adjList.get(v).add(new Pair(weight, u)); }
@avvarunithinvenkatasaisank5964
@avvarunithinvenkatasaisank5964 7 ай бұрын
canu provide full code
@TarunKumarSaraswat
@TarunKumarSaraswat Ай бұрын
thanks
@hardikjain-brb
@hardikjain-brb 11 ай бұрын
actually better
@ujjwalraj9837
@ujjwalraj9837 Жыл бұрын
It's demotivating how quickly he codes it up with such ease... like bro we get atleast 4-5 bugs everytime
@priyanshvatsal9791
@priyanshvatsal9791 Жыл бұрын
Understood 😇
@hope-jh7bv
@hope-jh7bv 6 ай бұрын
understood💙
@sumitnagar8367
@sumitnagar8367 4 ай бұрын
what's the need of condition if(!vis[adjnode]) if we are already concern about if(vis[node]){ continue; }
@_MS98
@_MS98 Жыл бұрын
Thanks 🐻‍❄🐻‍❄
@debajyatibanerjee5480
@debajyatibanerjee5480 2 жыл бұрын
Understood!
@sanketh768
@sanketh768 Жыл бұрын
I think there's a mistake in TC calculation. getting the min element from minHeap which is peek or poll is O(1) and not O(E), at least in java Please correct me if i'm wrong
@Maddy_ke_Papa
@Maddy_ke_Papa Жыл бұрын
Picking smallest elment is O(1) but he is removing it as well. so due to hipyification rearrangement of pq would take place resulting the time complexity of O(logE).
@sanketh768
@sanketh768 Жыл бұрын
@@Maddy_ke_Papa got it now, thanks for the clarification
@iamnoob7593
@iamnoob7593 Жыл бұрын
@@sanketh768 Tc is suppose to be ElogE + (E)2logE
@iWontFakeIt
@iWontFakeIt 6 ай бұрын
mic quality >>>>
@SurajSharma-z9p
@SurajSharma-z9p 7 ай бұрын
Why would 2,3,2 be picked before 2,4,2? If there's a clash in min value, FIFO should be applied right since it's a queue after all?
@23ritik
@23ritik 2 жыл бұрын
Sir make start array and strings series also please for interview purpose
@akashsahu2571
@akashsahu2571 Жыл бұрын
yes
@Now_I_am_all_fired_up
@Now_I_am_all_fired_up 2 жыл бұрын
Plz make vedion on : Bridges in a graph
@pratikgaikar9383
@pratikgaikar9383 7 ай бұрын
Prims algo always start with least edge weight not random
@SadhanaSharma
@SadhanaSharma Жыл бұрын
Thank you sirrrrrrr
@dinakarrajkotipalli2250
@dinakarrajkotipalli2250 5 ай бұрын
if you watch jenny lecture and combine the intution part here it would be excellent
G-46. Disjoint Set | Union by Rank | Union by Size | Path Compression
42:15
G-44. Minimum Spanning Tree - Theory
7:59
take U forward
Рет қаралды 144 М.
Twin Telepathy Challenge!
00:23
Stokes Twins
Рет қаралды 119 МЛН
If people acted like cats 🙀😹 LeoNata family #shorts
00:22
LeoNata Family
Рет қаралды 23 МЛН
СКОЛЬКО ПАЛЬЦЕВ ТУТ?
00:16
Masomka
Рет қаралды 3,5 МЛН
Lecture 96: Minimum Spanning Tree || Prim's Algorithm
33:04
CodeHelp - by Babbar
Рет қаралды 147 М.
I Solved 1583 Leetcode Questions  Here's What I Learned
20:37
ThePrimeTime
Рет қаралды 740 М.
3.5 Prims and Kruskals Algorithms - Greedy Method
20:12
Abdul Bari
Рет қаралды 2,9 МЛН
This Algorithm is 1,606,240% FASTER
13:31
ThePrimeagen
Рет қаралды 853 М.
G-47. Kruskal's Algorithm - Minimum Spanning Tree - C++ and Java
13:11
take U forward
Рет қаралды 200 М.
Why is Python 150X slower than C?
10:45
Mehul - Codedamn
Рет қаралды 18 М.
Prim's Minimum Spanning Tree Algorithm | Graph Theory
14:53
WilliamFiset
Рет қаралды 125 М.
Twin Telepathy Challenge!
00:23
Stokes Twins
Рет қаралды 119 МЛН