12. Greedy Algorithms: Minimum Spanning Tree

Sdílet
Vložit
  • čas přidán 3. 03. 2016
  • MIT 6.046J Design and Analysis of Algorithms, Spring 2015
    View the complete course: ocw.mit.edu/6-046JS15
    Instructor: Erik Demaine
    In this lecture, Professor Demaine introduces greedy algorithms, which make locally-best choices without regards to the future.
    License: Creative Commons BY-NC-SA
    More information at ocw.mit.edu/terms
    More courses at ocw.mit.edu

Komentáře • 110

  • @freccia9500
    @freccia9500 Před 6 lety +230

    Prim's algorithm starts 42:20
    Kruskal's algorithm : 1:06:00

  • @mohansinghrawat4324
    @mohansinghrawat4324 Před 7 lety +15

    Sir Erik you are best at teaching.. thankyou for the support...

  • @neerajkrishna1983
    @neerajkrishna1983 Před 3 lety +9

    Erik Demaine is one of the best Instructors!

  • @trinhngocdieu
    @trinhngocdieu Před 2 lety +22

    Really appreciate the MIT resource on this. Erik is an amazing teacher!

  • @sgzerolc
    @sgzerolc Před 2 lety +6

    correctness for Prim's algorithm 52:01
    correctness for Kruskal's algorithm 1:15:35

  • @Adi1995cv
    @Adi1995cv Před 7 lety +3

    Perfect Textbook lecture. Thank you

  • @inadaizz
    @inadaizz Před 3 lety +1

    I really enjoy this professor. Thank you MIT and Professor Demaine.
    Regards from The University of Toledo.

  • @ryancocuzzo6322
    @ryancocuzzo6322 Před 5 lety +10

    Wow. This guy is good. Very impressed with this lecture.

    • @aw6507
      @aw6507 Před 2 lety

      yeah dude is a genius

  • @LF58888
    @LF58888 Před rokem +11

    Im in the top 500 universities, and still finding youtube helping me more then my prof....

    • @cosmic_gate476
      @cosmic_gate476 Před 4 měsíci +4

      Professors are always excellent researchers, but not always good teachers.

    • @LF58888
      @LF58888 Před 4 měsíci

      @@cosmic_gate476 yeah thats so true :***(

  • @pourkavoosmedicalllcpourka7429

    What an excellent lecturer! Very clear and concise.

  • @soumadipranjanbiswas1779
    @soumadipranjanbiswas1779 Před 4 lety +2

    Thank You. Sir, you are an amazing teacher. Thank you for your videos, they are so clear and easy to understand. However, I'm a little confused still about the running time of Prim's. Would anyone be able to explain how you can decrease a key in a Fibonacci heap in constant time? If you were implementing prim's with a regular min-heap, would the running time change from O(Vlog(V) + E) to O(Vlog(V) + Elog(V)) to reflect the slower decrease key operation? (normal heaps, as I understand, take log(n) time to decrease the value of a key, correct?)

  • @AshishKumar-zx6zz
    @AshishKumar-zx6zz Před 2 lety +1

    One of the best teachers

  • @parkamark
    @parkamark Před 4 lety +15

    I've just utilised Kruskal's algorithm to solve a real-world problem we were facing at the company I work at. It is a very simple and elegant algorithm to implement. As of writing, it's solved our requirement of finding a spanning tree of a connected cyclic graph containing around 80 nodes, but we may have future instances with even more nodes (hundreds!). In our setup, none of the edges have weights so it just picks a random edge each time, effectively producing an arbitrary spanning tree upon each invocation of the problem, which is fine for what we need it for.
    Excellent video!

    • @juliancohn7662
      @juliancohn7662 Před 3 lety +10

      If the edges have no weight than any search algorithm (dfs, bfs) will find a spanning tree

  • @shivanshmishra752
    @shivanshmishra752 Před rokem

    First time in my life loving the proofs

  • @hannahdo980
    @hannahdo980 Před 3 lety +13

    That was a valuable lecture... But that chalkboard almost gave me mild asthma 😂

  • @lx4302
    @lx4302 Před rokem

    Amazing instructor

  • @bernardoamorim9495
    @bernardoamorim9495 Před 7 lety

    Are both vertices sets from the example starting @ 14:20 supposed to be connected on the spanning tree, with paths that do not include the edge e?

    • @hekkenikken
      @hekkenikken Před 7 lety

      If I understand your question, you're asking if both U and V are part of the MST. Answer is yes, because if edge e={u,v} is part of the MST then both vertex U and vertex V has to be part of the MST.
      Also for your second question "which paths do not include edge e={u,v}?", the answer it that there can be many paths which do not include that edge. Those paths a higher cost than the path edge e={u,v} is part of, and therefore does not create a MST.

  • @ninadsachania3652
    @ninadsachania3652 Před 2 lety

    Great lecture!

  • @TheKarateKidd
    @TheKarateKidd Před 4 lety +3

    This guy is a pro at writing on a chalkboard.

  • @journeytowardslife9830

    Erik is a genius !

  • @kentemershonyucra3251
    @kentemershonyucra3251 Před 8 lety

    Its correct proof the optimal substructure only by cut y paste that show in Cormen in programming dynamic chapter, if T* = T contracting a edge, and T = w(edge) + T*, suppose that T is minimum, if T* is not minimum, I can copy a minimum spanning tree T** here and, we get a T not is minimum, what is a contradiction.

  • @intuitivej9327
    @intuitivej9327 Před 3 lety

    Wow...!i like his lecture.

  • @dr.mohamedaitnouh4501
    @dr.mohamedaitnouh4501 Před 7 měsíci

    Does anyone know which microphone this professor is using? really crisp and clear! thanks!

    • @mitocw
      @mitocw  Před 7 měsíci

      It was most likely a wireless lav microphone from Sony. Not sure what exact model... it was seven years ago.

  • @eiebfiebrkcfne5399
    @eiebfiebrkcfne5399 Před 4 lety +2

    33:04 exchange argument (cut and paste argument)

    • @lumiere2598
      @lumiere2598 Před 2 lety +1

      yea the name confuses me, and turns out it is just the exchange argument 😂

  • @hectorbarajas9670
    @hectorbarajas9670 Před 6 lety +1

    @30:38 he says a crossing edge is defined by whether or not it has a vertex in V and the other vertex not in V. Did he mean to say a vertex is in S and the other is not in S?

  • @yifanxu3423
    @yifanxu3423 Před 5 lety

    @ 25:41 isn't that T* was cut to two subtrees since he was deleting the edge instead of merging it? can we say two trees is a spanning tree then?

    • @mystmuffin3600
      @mystmuffin3600 Před 3 lety

      No he deletes the edge AND merges the vertices, so it's still a single spanning tree. He says that like literally seconds later - "Contraction preserves connectivity"

  • @ajinkyagaikwad5888
    @ajinkyagaikwad5888 Před 4 lety

    awesome

  • @inordirection_
    @inordirection_ Před 5 lety +1

    What an excellent teacher.
    However, I'm a little confused still about the running time of Prim's. Would anyone be able to explain how you can decrease a key in a fibonacci heap in constant time? If you were implementing prim's with a regular min-heap, would the running time change from O(Vlog(V) + E) to O(Vlog(V) + Elog(V)) to reflect the slower decrease key operation? (normal heaps, as I understand, take log(n) time to decrease the value of a key, correct?)

    • @yosrym93
      @yosrym93 Před 4 lety

      Yes.
      Given that you are using an adjacency list:
      Fibonacci Heap Priority Queue -> O(|V|.log|V| + |E|)
      Min-Heap Priority Queue -> O((|V|+|E|)log|V|)
      If you are using a matrix instead of adjacency list, for every V you will loop through all vertices instead of just its degree, however, you still perform operations only when there is an edge. So:
      Min-Heap -> O(|V^2| + (|V| + |E|) log |V|) -> O(|V|^2 + |E| log |V|).
      Fibonacci Heap -> O(|V|^2 + |V| log |V|) -> O(|V|^2).
      |V| -> # of Vertices
      |E| -> # of Edges

    • @juliogomez1850
      @juliogomez1850 Před rokem

      @@yosrym93 bro be honest are you a robot

  • @kyniemxotxa98
    @kyniemxotxa98 Před 7 lety

    doesn't the picture @ 19:20 says that the graph is cyclic? But spanning trees are acyclic. Looks like a case of a bad example, or am I missing something?

    • @chrisfischer5380
      @chrisfischer5380 Před 6 lety +4

      Spanning tree must be acyclic but that doesn't mean the graph has to be

    • @anonymoususer5402
      @anonymoususer5402 Před 6 lety

      Graph is cyclic and spanning trees are not

  • @hemantdhanuka5919
    @hemantdhanuka5919 Před 7 lety +39

    Totally Impressed with U sir , why i find u so late... u are fanstastic teacher

  • @eeee8677
    @eeee8677 Před 6 lety +48

    man I wish I went here );

  • @fracturedude
    @fracturedude Před 5 lety +10

    @27:05 in what situation is w(T') < w(T* - e)? Isn't w(T') = w(T* - e)?

    • @archidar1
      @archidar1 Před 4 lety +4

      Before he wrote that he said that T' is the minimum spanning tree of a graph with G/e nodes.
      So by definition w(T')

    • @user-wt7ut4xj5r
      @user-wt7ut4xj5r Před 3 lety

      @@archidar1 thx i've been looking for this

  • @mostafasaadinasab6338
    @mostafasaadinasab6338 Před 4 lety

    #besten#Episode#Liebe#Soll#schönen#Highlight#

  • @RamshaRana
    @RamshaRana Před 7 lety +1

    so cool (y)

  • @somerandomguy8361
    @somerandomguy8361 Před 3 lety

    Where is recitation 3 lecture?

    • @mitocw
      @mitocw  Před 3 lety

      Sorry, recitation 3 is not available.

  • @mdaud1995
    @mdaud1995 Před 7 lety

    @17:00 onwards, if an edge(red) from 1st part ends in 2nd part, then the graph would not be an MST...but we have already supposed it to be a MST with e being an edge....
    Please clarify this doubt....!

    • @mystmuffin3600
      @mystmuffin3600 Před 3 lety

      if you delete edge e (and the components are still connected), you are in essence creating a new MST with a min red edge

  • @3alabo
    @3alabo Před 3 lety

    this guy is so fucking awesome

  • @Loukas_Anastasiadis
    @Loukas_Anastasiadis Před 7 lety +2

    wish i could i understand what you say man, i really tried. thanks for the support though.

  • @shashwattyagi1417
    @shashwattyagi1417 Před 3 lety +1

    17:30

  • @emanabdelhaleem7561
    @emanabdelhaleem7561 Před 5 měsíci

    It's was a shock for me and a good push too knowing that even professors at MIT need to look to a paper while building a proof!

  • @bernardoamorim9495
    @bernardoamorim9495 Před 7 lety

    @38:05, what if u and u' are connected by a path that includes e' ?

    • @adamrichter8792
      @adamrichter8792 Před 4 lety

      I believe that Professor Demaine made a slight error at 36:25 relevant to your question in his writing of a proof that every least weight edge that crosses a cut of an (undirected) graph is part of a minimum spanning tree of that graph. Just before that, he talked about how, given a possibly different minimum spanning tree, T*, there was a unique path from u to v in T* and that that unique path also must cross the cut, but then he did not use that lemma in writing the proof. In his proof, he wrote that we could choose any edge e' in T* that crosses the cut. I think he meant to put a further condition on e' that it must also be one of the edges in the path from u to v within T*. That way, removing e' disconnects the subgraphs containing u and v, and then adding e reconnects them without creating a cycle.

  • @ivyhe7234
    @ivyhe7234 Před 8 lety

    What's the thing with the frisbee?

    • @arbadon
      @arbadon Před 8 lety +3

      Each time someone gives a valid answer/proposal on one of the professors questions, they get a frisbee, although it used to be pillows!

  • @mohamedayssarbenelhedi2207

    how can i get acces to more lessons and PDF files , i am a student at a german university " RWTH aachen and i am interesed in having the textbooks to read please

    • @mitocw
      @mitocw  Před 8 lety +3

      See the course on MIT OpenCourseWare for more course materials (lecture notes, exams with solutions, assignments with solutions, recitations) at ocw.mit.edu/6-046JS15.

    • @mohamedayssarbenelhedi2207
      @mohamedayssarbenelhedi2207 Před 8 lety +1

      Yeah thnx I have checked , but some of them are limited , I don't have full access , for exemple I want operating system concepts , there is only notes , but no full lecture

    • @andrewspencer22
      @andrewspencer22 Před 7 lety

      Not every class has lectures. Generally what you see on the site is the resources they have.

  • @niteeshchaturvedi2754
    @niteeshchaturvedi2754 Před 6 lety +3

    after watch 1 hour of super cool lecture, my brain is still blank .will anyone suggest a brain booster tonic ?:( :)

  • @jonathanibarra8236
    @jonathanibarra8236 Před 3 lety +3

    I think the camera man is the best attentive and hope he’s taking notes too lol

  • @kevnar
    @kevnar Před 2 lety +2

    Corporations pay employees as little as possible: the greedy choice. But if all corporations paid employees abundantly, they'd make more sales when the public has more disposable income, and they'd be richer in the long run. The locally optimal solution is not always the best.

  • @wolfinthesuit
    @wolfinthesuit Před 2 lety

    Thanks you MiT now i hate science and hate algorithm and hate myself for failing

  • @WorldOfPersianDoc
    @WorldOfPersianDoc Před 2 lety

    I'm preparing for my PhD algorithm qualifying exam and this video helps me to understand the proof. However, signs are too much and they can be more simplified. Also, class notes helped but the graphs are not in the class notes which could be so much useful to understand the proof easier.

  • @mtslr7378
    @mtslr7378 Před 10 měsíci

    Lucky, I didn't take those kind of classes.

  • @mons911
    @mons911 Před rokem

    I wanted to be on those benches! 💔

  • @JiuxiM
    @JiuxiM Před 3 lety +2

    Since the last lecture, Eric has been trying to emphasize that purple is better than blue. Whereas in lecture 10 Srinivas said blue is better than purple. Interesting...

  • @user-tk2jy8xr8b
    @user-tk2jy8xr8b Před 5 lety

    > tree = directed connected acyclic graph
    a ->- b ->- d
    └-->- c ->-┘
    according to the definition this must be a tree, but it's not

  • @papetatedouces
    @papetatedouces Před 3 lety

    18:00 best way to contract an STD

  • @maxyakovlev505
    @maxyakovlev505 Před 6 lety

    43:32
    seems like nicki minaj has been using prims algorithm to grow her ass

  • @meredithsui9532
    @meredithsui9532 Před 4 lety

    confusing

  • @qaz123amangupta
    @qaz123amangupta Před 5 lety +1

    i cant understand

    • @tr233
      @tr233 Před 5 lety +1

      you are not alone, but exerciese think about out what the condition what the small steps

  • @rachitrajput915
    @rachitrajput915 Před 4 lety

    Itne saare black board.......

  • @danielnzuma9070
    @danielnzuma9070 Před 3 měsíci

    Added this comment cause I cant like twice
    Thanks Eric

  • @shrimatkapoor2200
    @shrimatkapoor2200 Před 4 lety

    Why is my professor so shit, he literally reads of slides.. And doesn't even make sense doing it

  • @holdenmcgroin8917
    @holdenmcgroin8917 Před 5 lety

    This guy writes too much

  • @autumnleaves9917
    @autumnleaves9917 Před 7 lety

    too much writing. Why didn't he use a powerpoint

    • @surajkakkad7363
      @surajkakkad7363 Před 6 lety +39

      powerpoint kills actual thinking.

    • @ilyakopyl
      @ilyakopyl Před 5 lety

      Such online lectures were my motivation to learn the cursive writing (not native speaker) and fast writing.

    • @dylancutler1978
      @dylancutler1978 Před 5 lety +11

      It's for the benefit of the students, it takes time to write it by hand, time they also need to write notes at a pace that allows them to continue to pay attention while also understanding what they are writing.
      This stuff requires thought to understand, and even MIT students need time to grasp new information.

    • @TheKarateKidd
      @TheKarateKidd Před 4 lety +3

      My university banned teachers from using PowerPoint during math/science lectures. It eliminates demonstrating the entire thought process and pace behind the critical thinking needed to learn and solve these concepts.

  • @hariharane51
    @hariharane51 Před 7 lety

    worst 1 hr i ever spent !!!