Prims algorithm | MST | Code implementation

Поделиться
HTML-код
  • Опубликовано: 28 июл 2020
  • In this video,I have explained the prim's algorithm which is used to find the minimum spanning tree.I have first explained the intuition for Prims algorithm and then i have shown a simple example.After that, I have shown a proper CODE algorithm using large example and at the end of the video,I have explained the CODE implementation of prims algorithm.I have explained this algorithm in an easy and simple way to follow.This is a greedy algorithm for finding minimum cost spanning tree.CODE LINK is present below as usual. If you find any difficulty or have any query then do COMMENT below. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful...CYA :)
    ========================================================================
    Join this channel to get access to perks:
    / @techdose4u
    INSTAGRAM : / surya.pratap.k
    SUPPORT OUR WORK: / techdose
    LinkedIn: / surya-pratap-kahar-47b...
    WEBSITE: techdose.co.in/
    TELEGRAM Channel LINK: t.me/codewithTECHDOSE
    TELEGRAM Group LINK: t.me/joinchat/SRVOIxWR4sRIVv5...
    =======================================================================
    CODE LINK: gist.github.com/SuryaPratapK/...
    USEFUL VIDEOS:-
    Disjoint Set (Simple): • Disjoint Set | UNION a...
    Disjoint set UNION by RANK and Path Compression: • Disjoint set UNION by ...

Комментарии • 174

  • @kashishjain3179
    @kashishjain3179 2 года назад +34

    was having difficulty in understanding prims for a very long but the way you explained cleared all my doubts. THANK YOU SO MUCH SIR

  • @mahadevsai3748
    @mahadevsai3748 3 года назад +21

    sir i have joined a course in coding blocks in that prim's algo is unable to understaand ,when i seen this video urs explaintation is 1000 times bettr and best than coding blocks

    • @techdose4u
      @techdose4u  3 года назад

      ❤️

    • @user-nm4vn9tq5o
      @user-nm4vn9tq5o 2 года назад

      How much was the price of DSA course? And was it worth taking?

    • @devrajgoswami4357
      @devrajgoswami4357 Год назад

      @@user-nm4vn9tq5o bro he literally said he was unable to understand and here you are asking 😂

  • @rupaksarkar4600
    @rupaksarkar4600 Год назад +5

    after watching dozens of videos finally i could understand prims .Thanks man

  • @mainakmondal5228
    @mainakmondal5228 3 года назад +10

    Concepts are getting clearer day by day from your videos...thank you.

  • @lingyunsu5207
    @lingyunsu5207 2 года назад +2

    Thank you so much! This is the clearest and easiest video for me to understand the algorithm!

  • @avidlearner7393
    @avidlearner7393 3 года назад +21

    This is so far the best video for Prim's algorithm on RUclips. Thanks for such a great explanation.

  • @vasudevrao1434
    @vasudevrao1434 3 года назад

    One of the best resource among all the free and paid courses out there 🙏

  • @mdrafiqulislam8233
    @mdrafiqulislam8233 2 года назад

    This is the simplest and easiest video in the internet. Thank you.

  • @nishidwivedi1308
    @nishidwivedi1308 7 месяцев назад

    So far the best explanation that I have come across. Amazing!

  • @moeen007
    @moeen007 2 года назад +4

    Love you 3000 brother, I have never been so comfortable learning the DSA. Lots of love ! :)

  • @sooraj_sp_11
    @sooraj_sp_11 Год назад

    thank you so much ,, your efforts gives me lot of knowledge ,, I guaranteed that there will no any video on MST who explains it in such details ....... keep inspiring ...

  • @assemmedo8
    @assemmedo8 9 месяцев назад

    Really great explanation, detailed and really makes you know what's happening step by step

  • @heidarsafari4753
    @heidarsafari4753 8 месяцев назад

    Thank you very much for sharing the code, sir. I could program Prim's algorithm in Matlab and find the MST for my own 480-vertex graph by taking advantage of your code programmed in C++ and your complete explanation in the video. I wish all the best for you.

  • @mahipalsingh-yo4jt
    @mahipalsingh-yo4jt 3 года назад +2

    successfully implemented by watching your video. Thanks sir.

  • @shalinikumari5532
    @shalinikumari5532 3 года назад +2

    Great explanation ,amazing process.Very much helpful

  • @asifiqbalsekh
    @asifiqbalsekh 2 года назад

    Ab pta nehi sukriya ada kaise kare...lekin ap ne jo effort dala hai isko samjha ne ke liye , hat's off.... Salam apke patience level ko samjhane ke time.... Dil se sukriya....

  • @amanbhandari349
    @amanbhandari349 3 года назад +3

    Best channel ever seen for ds algo . ❤❤❤

  • @DarkUnknown7
    @DarkUnknown7 3 года назад +11

    You helped a lot ! Appreciated !

  • @sejalrai30
    @sejalrai30 Год назад

    thank you so much you know tht where student get stuck ...its appreciable

  • @user-pg8wq2pw1f
    @user-pg8wq2pw1f Год назад

    You have explained it very well .Thank you very much.

  • @dhanashreegodase4445
    @dhanashreegodase4445 2 года назад

    Thanks for such a great explanation. never stop making videos

  • @mdaasil2329
    @mdaasil2329 Год назад +1

    Thanks bro. was struggling to find a proper cpp implementation for past 4 hours!

  • @puneethj9920
    @puneethj9920 3 года назад

    Awesome! Great Explanation👏

  • @smartwork7098
    @smartwork7098 11 дней назад

    Beautiful explanation!

  • @jaskiranmalhotra989
    @jaskiranmalhotra989 3 года назад

    Best Explaination so far :)

  • @sujoyseal195
    @sujoyseal195 3 года назад +4

    In line 46 of your code , during step 3 I think it should be graph[u][j]

  • @ranjanreddy623
    @ranjanreddy623 Год назад

    This explanation deserves more views😍😍

  • @ABHISHEKKUMAR-wc9ke
    @ABHISHEKKUMAR-wc9ke 2 года назад +2

    best explaination on youtube

  • @liquidred257
    @liquidred257 3 года назад +3

    The fact that you included a parent array finally helped me figure this out (I think). so the weight associated with a given node is the weight from the parent to the node in question? Which is why node 3, perse, dosen't have a weight of 1?

  • @prateekjain7623
    @prateekjain7623 3 года назад +2

    sir,can we use vetor of vector in pair ??
    so that we not to use adjanency matrix to reduce time complexicity??

  • @suvamgupta2914
    @suvamgupta2914 3 года назад

    Thanks for making these videos
    ❤️

  • @nonpreservative8354
    @nonpreservative8354 3 года назад +6

    Please make a video for Prim's algo using heap and adjacency matrix with time complexity O(ElogV)

  • @prateeksinghal630
    @prateeksinghal630 3 года назад +3

    Really Awesome Video !!
    It deserves all the likes !!

  • @kunalsoni7681
    @kunalsoni7681 4 года назад +3

    Nice explanation 😊 thanks for to making graph series

  • @Thoughs_05
    @Thoughs_05 3 года назад +2

    Great I understood everything thanks bro

  • @nishithramanuj509
    @nishithramanuj509 2 года назад

    Superb explanation sir

  • @siddharthpunmiya2744
    @siddharthpunmiya2744 3 года назад

    Hey In prim why do you need to relax vertex it is a method to find minimum spanning tree by picking up adjacent edges only, not by weight of the vertex

  • @surajtopal9940
    @surajtopal9940 3 года назад +2

    thank you so much sir :)

  • @067_prahladmondal7
    @067_prahladmondal7 2 года назад

    great explaination vaiya!

  • @user-sz2sl6lo2m
    @user-sz2sl6lo2m 2 года назад

    Which software have you used ( for virtual blackbaord ), It feels so easy to use. And thank you for your nice explanation.

  • @varnittyagi2693
    @varnittyagi2693 3 года назад +1

    Great Explanation

  • @kongzilla2897
    @kongzilla2897 3 года назад +1

    Thank you so much :)

  • @tsupreetsingh
    @tsupreetsingh 3 года назад +5

    very clear and concise !

  • @impatientgaming9868
    @impatientgaming9868 6 месяцев назад

    Good explanation!!!

  • @surajmaity6194
    @surajmaity6194 Год назад

    THANK YOU SO MUCH

  • @RahulGupta-xg6vs
    @RahulGupta-xg6vs 4 года назад +2

    There is no doubts,great..,👌👌👌👌👌

  • @manikantabandla3923
    @manikantabandla3923 3 года назад +4

    Thank you @techdose for creating a playlist of graph algorithms.
    I think we can implement the prim's algorithm in O(V(logV)) with the use of min-heap.
    I would be highly thankful to you if u can provide links of Leetcode problems related to every algorithm u are going to explain.

    • @techdose4u
      @techdose4u  3 года назад

      I haven'r researched on leetcode problems for these topic. Once I find leetcode similar problems then I will add to the playlist at proper place.

    • @ayonsinha2075
      @ayonsinha2075 Год назад

      no It can not be done i.g beacause in distance array we are storing the distance from source to dest nodes... so if herer inthis example shortest distane to reach 0 from 3 is 6 where so it causes problem..because we have to stiore the total cost to traverse the all nodes of graph...if u use djkistra it always add the cost source to destination..so currently we are standing at node it does not matter beacuse if that node could be the parent of target node where we are standing at...then in prims or according to MST we add the distance fom it's parent to the target or adjacent node but in dijsktra it will add up all upto source from parent+dest cost in the main cost...but we can prevent it in one way if we know who is the parent of that target node then we can subtract the cost of source to parent from our total cost but it will make things comlex and I am not sure whether it may work or not to get the proper res ...then we need 0(n) more space

  • @mohitkamal4864
    @mohitkamal4864 4 года назад +1

    Excellent one🤩🤩

  • @ujeshnada7281
    @ujeshnada7281 3 года назад +1

    Best video of MST....

  • @impatientgaming9868
    @impatientgaming9868 6 месяцев назад

    Good one

  • @arpanbanejee5143
    @arpanbanejee5143 2 года назад +4

    Thanks for the video!!, I have one doubt here, even if we remove the MST SET from this algo, it seems to be working(in the efficient implementation using Priority Queue) because we are only pushing those vertices in the queue whose edge weight is less than the already existing edge weight at that vertex, so there is no chance we put an already visited vertex because its weight will be the same(1->0 is same as 0->1) So, why exactly do we need this visited(MST SET)? It's the same with Dijkstra, it works even without the Priority queue and visited array( but the Time complexity takes a hit for some test cases). Am I understanding it correctly? Or did I miss anything

    • @arpanbanejee5143
      @arpanbanejee5143 2 года назад

      After going through some examples, I can conclude that we need the visited(MST SET) here, but if you ignore the TC, in Djikstra you don't need it, it will fetch u the correct results, but here in PRIMS Algo you will get wrong and.
      Take this example- undirected graph-
      0->1 cost 12
      1->2 cost 6
      0->2 cost 18
      take the corresponding opp edges as well since this is an undirected graph
      Now, if you remove the visited array, the key[] will look like this-[0, 6, 6]
      here node 1 is connected to 2 and vice versa, which is not correct.
      The correct key[] should be-[0,12,6]
      0 connected to 1 and 1 connected to 2.
      Djikstra without Priority Queue and Visited array- Leetcode 1514
      class Solution {
      class Node{
      int v;
      double weight;
      Node(int v,double weight){
      this.v=v;
      this.weight=weight;
      }
      }
      public double maxProbability(int n, int[][] edges, double[] succProb, int start, int end) {
      // build adjaceny list
      List[] adj=new ArrayList[n];
      for(int i=0;i

  • @divanshmahajan1769
    @divanshmahajan1769 4 года назад +1

    Plz post solutions of graph problems of hackerrank also ...

  • @souviknandi9298
    @souviknandi9298 3 года назад +1

    nicely explained

  • @hemanthch8155
    @hemanthch8155 3 года назад

    It is better to start from Oth node...Coz,If we find Min weight node at the middle it is giving More weighted Output for some trees..

  • @KeyAndLock77
    @KeyAndLock77 7 месяцев назад

    Is there one flaw in algorithm that the
    value[j] should be graph[U][j] + value [U]
    value[j] = graph[U][j] + value [U];
    to correctly update distance from the root node?

  • @ayyappareddy4461
    @ayyappareddy4461 3 года назад +1

    Thank you very much sirrrrrrrrrrr

  • @venuvenu2719
    @venuvenu2719 4 года назад +1

    Please explain the problem-find the longest path in binary tree

  • @kunalpatidar2849
    @kunalpatidar2849 3 года назад

    How we know that the parent of node 4 is node 3, it might be 2 because last visited node is 2 ??.
    (at time 21:00 in video)

  • @yihongliu7326
    @yihongliu7326 2 года назад

    Thank you for the amazing video! Just q quick question -- why do we repeat (V-1) times? Is it because each time we only connect 1 edge between 2 vertices, and we need (V-1) vertices in total?

    • @veera9963
      @veera9963 Год назад +1

      Because for the last vertice we don't have to search for edge with minimum weight because if we do that then we will get a loop in the tree ... which should be avoided

    • @amansahil5721
      @amansahil5721 Год назад

      because for the last vertices all its adjacent will already be processed

  • @mdizrail792
    @mdizrail792 3 года назад +1

    Sir can we use priority queue for selectioning the minimum edge ?

    • @techdose4u
      @techdose4u  3 года назад +2

      No. You need to pick adjacent vertices only. In Kruskal's you can use priority queue.

  • @theprofessor1663
    @theprofessor1663 2 месяца назад

    Best 🙌🏻🙌🏻🙌🏻🙌🏻🙌🏻🙌🏻🙌🏻🙌🏻

  • @satishshingade8514
    @satishshingade8514 3 года назад +1

    you are amazing !!!

  • @Mauglus
    @Mauglus 4 года назад +1

    What's the difference to Dijkstra? Only that we continue until all nodes are explored?

    • @techdose4u
      @techdose4u  4 года назад +1

      No. They both have different goals and so, the MST found by Prim's may not have the shortest path between 2 nodes. Read this: stackoverflow.com/questions/14144279/difference-between-prims-and-dijkstras-algorithms

  • @MAHMOODAHMAD-nr4wo
    @MAHMOODAHMAD-nr4wo 3 года назад +1

    I think prim's algorithm is much similar to Dijkstra's except for the part where we store processed vertices in the set.
    This is my opinion.
    Correct me if I am wrong

    • @yuvrajjoshi4893
      @yuvrajjoshi4893 3 года назад

      No, in Dijkstra's algo you add the (value at the current node + edge weight of the adjacent node to be reached) and if it is smaller than its previous value (at the adjacent node to be reached) then only you update. But in Prim's you don't add the value at the current node before comparing, you simply check if the edge value to reach the adjacent node is smaller than its previous value, and then update if necessary.

    • @MAHMOODAHMAD-nr4wo
      @MAHMOODAHMAD-nr4wo 3 года назад +1

      @@yuvrajjoshi4893 if we write a code for dijkstra using minHeap (set,priority queue) the code is somewhat similar except for the Operation part which differs in Dijkstra and prims.

    • @yuvrajjoshi4893
      @yuvrajjoshi4893 3 года назад

      @@MAHMOODAHMAD-nr4wo yeah I know that. I was only telling the part where they differ.

  • @bunnyrabits
    @bunnyrabits 4 года назад +6

    sir can you start a Placement Series , making videos on topic wise questions that you told in the "30 days placement video" , it will be very helpful as we all can follow your videos. If you can a video on per day basis😊.
    Like if you all agree guys.

  • @motivation_hubPJ
    @motivation_hubPJ 3 года назад +1

    can we use priority queue to get next min node ?

  • @bunnyrabits
    @bunnyrabits 4 года назад +1

    It will be great if you can share some must do questions, topic wise(6-10 Questions) for begginers like me.
    And again it wiil be great if you make videos on that questions. Thank you

  • @saranyas7629
    @saranyas7629 4 года назад +2

    I vote for going back to solving August daily challenges from Techdose

    • @techdose4u
      @techdose4u  4 года назад +2

      I am making a come back in August challenge :)

    • @saranyas7629
      @saranyas7629 4 года назад +2

      This is great news

    • @techdose4u
      @techdose4u  4 года назад +3

      But the videos may get uploaded the next day due to low processing power.

  • @vamsia5543
    @vamsia5543 3 года назад +2

    I could implement it without help such a great explaination thank a ton , could u please upload bridges and articulation points

    • @techdose4u
      @techdose4u  3 года назад +2

      Yea. It will soon come.

  • @ayushgarg5929
    @ayushgarg5929 4 года назад +2

    What if all adjacent nodes has same cost...which one we would select ?

    • @techdose4u
      @techdose4u  4 года назад

      Anyone will be fine. It depends on how you choose. In my case, I might choose the node with lower label.

    • @ayushgarg5929
      @ayushgarg5929 4 года назад +1

      @@techdose4u will this algo work if the graph is not completed. ??

    • @techdose4u
      @techdose4u  4 года назад

      You mean for disconnected graph?

    • @ayushgarg5929
      @ayushgarg5929 4 года назад +1

      @@techdose4u No...i meant to say if the graph wasn't like all pair of nodes were connected to each other ....then in that case also this algo works. ???

    • @techdose4u
      @techdose4u  4 года назад

      You mean a complete graph ryt. In that case, if you have multiple edges with same values then anyone can be picked and there will be multiple MST possible and anyone will be correct.

  • @supernova7870
    @supernova7870 4 года назад +1

    Sir, @8:37 what is the logic of expanding adjacently and not randomly, PlZz clear my doubt sir ??

    • @techdose4u
      @techdose4u  4 года назад +2

      Random expansion is Kruskal's method. Adjacent expansion is based on the idea that we have to connect all nodes to form MST. So there will be only 1 component. Therefore, even if we expand adjacently using greedy approach, it won't matter.

    • @supernova7870
      @supernova7870 4 года назад +1

      @@techdose4u Sir, if i apply dijistras algorithm on the graph mentioned in the problem and find shortest path for each node from source vertex and take only the shortest path for each node , then sir don't you think it will to form a MST , Sir i was getting a feel that prims uses dijistras algorithm indirectly, that's why iam asking .

    • @techdose4u
      @techdose4u  4 года назад +1

      Please watch my Dijkstra algo video. You will get this point cleared.

    • @supernova7870
      @supernova7870 4 года назад

      @@techdose4u okk sir.

  • @VivekJaviya
    @VivekJaviya 4 года назад +1

    which software you use??

    • @techdose4u
      @techdose4u  4 года назад +1

      Wacom pro inkspace sketch.io

  • @rakeshsinha9541
    @rakeshsinha9541 4 года назад +1

    Thanks

  • @sainikhil956
    @sainikhil956 3 года назад +2

    Sir can you please tell what is the use of mst array? i want to know intuition behind it
    because sometimes we might reach a node in less distance after declaring that mst node true..
    and what observations can we make from this algo?

  • @software3089
    @software3089 Год назад

    Can someone provide the same code of adjacency list?

  • @relaxthegamer
    @relaxthegamer Год назад

    Love u bro

  • @AbhishekRaj174
    @AbhishekRaj174 2 года назад

    what about findMin's time complexity, isnt that V too, so that would be V^3

  • @shaswatdas6553
    @shaswatdas6553 3 года назад +3

    Is it only me or it seemed like dijkstra and prims are very similar??🤔
    only one line difference in if statement

  • @mddilshadalam8561
    @mddilshadalam8561 3 года назад

    in which software do you write like this ?

    • @mddilshadalam8561
      @mddilshadalam8561 3 года назад

      do you write in computer like this or you use touchscreen laptop??

    • @psgoat1111
      @psgoat1111 3 года назад

      Sublime text it is..

    • @mddilshadalam8561
      @mddilshadalam8561 3 года назад

      @@psgoat1111 not about editor ( code writing stuff)

  • @shyamsingharoy4853
    @shyamsingharoy4853 Год назад

    How to find cost bro

  • @antimony0004
    @antimony0004 3 года назад

    share adjacency list code also

  • @avinaba_mazumdar
    @avinaba_mazumdar 3 года назад +1

    Wait you from Durgapur?

    • @techdose4u
      @techdose4u  3 года назад

      Yes right :)

    • @avinaba_mazumdar
      @avinaba_mazumdar 3 года назад

      ​@@techdose4u oh you studied at DAV, I'm from GTBPS, never checked out your schooling on LinkedIn my bad

  • @abhishekdasgupta1679
    @abhishekdasgupta1679 3 года назад +1

    can't understand the selectminvertex method properly, someone pls help

    • @techdose4u
      @techdose4u  3 года назад

      Please explain your doubt

    • @abhishekdasgupta1679
      @abhishekdasgupta1679 3 года назад +1

      vertex = i;
      minimum = value[i];
      }
      }
      return vertex;
      specially "return vertex" part

    • @techdose4u
      @techdose4u  3 года назад

      @@abhishekdasgupta1679 Vertex = i; is used to find the vertex which has minimum value. Minimum is used to find the minimum distance value and store its corresponding vertex in vertex variable. Both should be updated together.

    • @abhishekdasgupta1679
      @abhishekdasgupta1679 3 года назад +1

      @@techdose4u finally understood, thanks bro

    • @techdose4u
      @techdose4u  3 года назад

      Welcome :)

  • @nikhilbalwani5556
    @nikhilbalwani5556 3 года назад +1

    are you from NIT durgapur?

    • @techdose4u
      @techdose4u  3 года назад

      Yep

    • @nikhilbalwani5556
      @nikhilbalwani5556 3 года назад +1

      @@techdose4u placed?

    • @techdose4u
      @techdose4u  3 года назад

      Long back. I should say I was from NIT DGP 😅

    • @nikhilbalwani5556
      @nikhilbalwani5556 3 года назад +1

      @@techdose4u cool, can i find you on linkedin?

    • @techdose4u
      @techdose4u  3 года назад +1

      @@nikhilbalwani5556 It should be in the description or else find in description of latest video.

  • @tatu_indranil
    @tatu_indranil 2 года назад

    Can someone give me the C code using the same method as I need to implement this in C
    I understood the explanation but I don't know know much of c++ 😅😅

  • @kunalsoni7681
    @kunalsoni7681 4 года назад +2

    Sir please can you solve my doubt 😇
    Sir in Findmst() function have two loops
    Outer loop and inner loop takes v^2 time
    Sir but every run of outer loop also calling
    selectMinVertex () also takes linear time as V.

    • @kunalsoni7681
      @kunalsoni7681 4 года назад

      So I thinking that the time complexity should be v^3. but you are saying V^2 time complexity. Sir as we consider time of calling function or not 😇 in our prims algo ? I notice this when I writing code on my notebook

    • @Amit_Kumar_1999
      @Amit_Kumar_1999 4 года назад +2

      @@kunalsoni7681 This is simple implementation not efficient one. As shown in video that you could use adjacency list for better time complexity (Though I don't think in complete graph it would matter). To optimise it further use priority_queue so that we don't have to scan the entire edge array for the minimum value vertex.

    • @kunalsoni7681
      @kunalsoni7681 4 года назад +1

      @@Amit_Kumar_1999 thanks for sharing your suggestions 😇

    • @techdose4u
      @techdose4u  4 года назад +2

      You can use a heap to get O(E log V).

    • @kunalsoni7681
      @kunalsoni7681 4 года назад +1

      @@techdose4u okay sir 😊 thanking you

  • @AyushGupta-kb9iv
    @AyushGupta-kb9iv 4 года назад +1

    Hello Sir...
    Please make a video on given Problem...
    Count the number of subarrays having a given XOR
    Thank you...

  • @shaswatdas6553
    @shaswatdas6553 3 года назад

    INF = 10**12
    def pick_min(dist, mstset):
    min_i, val = min(
    enumerate(dist), key=lambda x: x[1] if mstset[x[0]] == False else INF)
    return min_i
    def prims(edge, V):
    dist = [INF for i in range(V)]
    dist[0] = 0
    mstset = [False for i in range(V)]
    parent = [-1 for i in range(V)]
    for i in range(V-1):
    u = pick_min(dist, mstset)
    mstset[u] = True
    for v, w in edge[u]:
    if mstset[v] == False and w < dist[v]:
    dist[v] = w
    parent[v] = u
    print('parent,curr,dist: ', *zip(parent, list(range(V)), dist))
    V = 6
    edge = {}
    edge[0] = [(1, 4), (2, 6)]
    edge[1] = [(0, 4), (2, 6), (3, 3), (4, 4)]
    edge[2] = [(0, 6), (1, 6), (3, 1)]
    edge[3] = [(2, 1), (1, 3), (4, 2), (5, 3)]
    edge[4] = [(1, 4), (3, 2), (5, 7)]
    edge[5] = [(4, 7), (3, 3)]
    prims(edge, V)

  • @b.sainathreddy4567
    @b.sainathreddy4567 3 года назад

    selectminv also take o(v) so it should be o(v3) correct me if i am wrong

  • @willturner3440
    @willturner3440 3 года назад +8

    Any body here for cc long 😂

  • @HIMANSHUSHARMA-zo2sg
    @HIMANSHUSHARMA-zo2sg 3 года назад

    I think this is djakstra's...

  • @shubhampatil2777
    @shubhampatil2777 2 года назад

    Algorithm can be improved in this way by eliminating that second loop to find out parent (Naming conventions are different here: weights=value, visited=setMST)
    int findMinAdjacentEdge(int graph[size][size], int vertex,int *weights, bool *visited, int *parents){
    int minWeight=INT_MAX, minIndex;
    for(int i=0;i

  • @dashrathyadav1476
    @dashrathyadav1476 4 года назад +1

    Bro..plz make ur vdos shorter...I have no issues..but I also want u to get good views...as ppl usually choose shorter vdos..

  • @farhanbajwa4954
    @farhanbajwa4954 6 месяцев назад

    You explained this algorithm wrong, because in prims we look for a next shortest visiting edge not just from a current vertex, but from all the vertex that have been visited so far.