12. Greedy Algorithms: Minimum Spanning Tree

Поделиться
HTML-код
  • Опубликовано: 3 мар 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

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

  • @freccia9500
    @freccia9500 6 лет назад +234

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

  • @sgzerolc
    @sgzerolc 2 года назад +6

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

  • @PeterHoward-r6p
    @PeterHoward-r6p День назад

    I really like the old style by using chalks and blackboards especially their snappy sounds

  • @hannahdo980
    @hannahdo980 3 года назад +13

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

  • @LF58888
    @LF58888 Год назад +13

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

    • @cosmic_gate476
      @cosmic_gate476 6 месяцев назад +7

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

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

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

  • @trinhngocdieu
    @trinhngocdieu 2 года назад +23

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

  • @mohansinghrawat4324
    @mohansinghrawat4324 7 лет назад +15

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

  • @neerajkrishna1983
    @neerajkrishna1983 3 года назад +9

    Erik Demaine is one of the best Instructors!

  • @pourkavoosmedicalllcpourka7429

    What an excellent lecturer! Very clear and concise.

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

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

  • @Adi1995cv
    @Adi1995cv 7 лет назад +3

    Perfect Textbook lecture. Thank you

  • @parkamark
    @parkamark 5 лет назад +16

    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 3 года назад +10

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

  • @ryancocuzzo6322
    @ryancocuzzo6322 5 лет назад +10

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

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

      yeah dude is a genius

  • @AshishKumar-zx6zz
    @AshishKumar-zx6zz 2 года назад +1

    One of the best teachers

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

    This guy is a pro at writing on a chalkboard.

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

    First time in my life loving the proofs

  • @soumadipranjanbiswas1779
    @soumadipranjanbiswas1779 4 года назад +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?)

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

    Great lecture!

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

    Amazing instructor

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

    Erik is a genius !

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

    Wow...!i like his lecture.

  • @kentemershonyucra3251
    @kentemershonyucra3251 8 лет назад

    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.

  • @hemantdhanuka5919
    @hemantdhanuka5919 7 лет назад +39

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

  • @eeee8677
    @eeee8677 6 лет назад +48

    man I wish I went here );

  • @scrappy-mvp
    @scrappy-mvp Месяц назад

    The proof of the greedy choice property is incorrect. You can’t exchange any edge crossing the cut with e to get the MST but you have to find the edge that is part of the cycle when you add e. And this uses the property of a cut that if an edge that crosses a cut is part of a cycle then there’s another edge of that cycle that crosses the cut too. And this cycle edge may or may not be the current edge we’re trying to exchange in the Tree.

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

    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!

  • @kevnar
    @kevnar 3 года назад +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.

  • @bernardoamorim9495
    @bernardoamorim9495 7 лет назад

    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 7 лет назад

      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.

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

    33:04 exchange argument (cut and paste argument)

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

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

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

    awesome

  • @hectorbarajas9670
    @hectorbarajas9670 6 лет назад +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?

  • @inordirection_
    @inordirection_ 5 лет назад +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 4 года назад

      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 2 года назад

      @@yosrym93 bro be honest are you a robot

  • @fracturedude
    @fracturedude 5 лет назад +10

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

    • @archidar1
      @archidar1 4 года назад +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 3 года назад

      @@archidar1 thx i've been looking for this

  • @Loukas_Anastasiadis
    @Loukas_Anastasiadis 7 лет назад +2

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

  • @yifanxu3423
    @yifanxu3423 5 лет назад

    @ 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 3 года назад

      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"

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

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

  • @kyniemxotxa98
    @kyniemxotxa98 7 лет назад

    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 6 лет назад +4

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

    • @anonymoususer5402
      @anonymoususer5402 6 лет назад

      Graph is cyclic and spanning trees are not

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

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

  • @niteeshchaturvedi2754
    @niteeshchaturvedi2754 6 лет назад +3

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

  • @dr.mohamedaitnouh4501
    @dr.mohamedaitnouh4501 9 месяцев назад

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

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

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

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

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

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

    this guy is so fucking awesome

  • @mdaud1995
    @mdaud1995 7 лет назад

    @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 3 года назад

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

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

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

  • @JiuxiM
    @JiuxiM 3 года назад +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...

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

    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.

  • @RamshaRana
    @RamshaRana 7 лет назад +1

    so cool (y)

  • @bernardoamorim9495
    @bernardoamorim9495 7 лет назад

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

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

      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.

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

    17:30

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

    I wanted to be on those benches! 💔

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

    Where is recitation 3 lecture?

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

      Sorry, recitation 3 is not available.

  • @mohamedayssarbenelhedi2207
    @mohamedayssarbenelhedi2207 8 лет назад

    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  8 лет назад +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 8 лет назад +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 8 лет назад

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

  • @user-tk2jy8xr8b
    @user-tk2jy8xr8b 5 лет назад

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

  • @ivyhe7234
    @ivyhe7234 8 лет назад

    What's the thing with the frisbee?

    • @arbadon
      @arbadon 8 лет назад +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!

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

    18:00 best way to contract an STD

  • @maxyakovlev505
    @maxyakovlev505 6 лет назад

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

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

    Itne saare black board.......

  • @qaz123amangupta
    @qaz123amangupta 5 лет назад +1

    i cant understand

    • @tr233
      @tr233 5 лет назад +1

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

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

    confusing

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

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

  • @danielnzuma9070
    @danielnzuma9070 4 месяца назад

    Added this comment cause I cant like twice
    Thanks Eric

  • @holdenmcgroin8917
    @holdenmcgroin8917 5 лет назад

    This guy writes too much

  • @autumnleaves9917
    @autumnleaves9917 7 лет назад

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

    • @surajkakkad7363
      @surajkakkad7363 6 лет назад +40

      powerpoint kills actual thinking.

    • @ilyakopyl
      @ilyakopyl 5 лет назад

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

    • @dylancutler1978
      @dylancutler1978 5 лет назад +12

      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 4 года назад +4

      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 7 лет назад

    worst 1 hr i ever spent !!!