12. Greedy Algorithms: Minimum Spanning Tree

Поділитися
Вставка
  • Опубліковано 25 сер 2024
  • MIT 6.046J Design and Analysis of Algorithms, Spring 2015
    View the complete course: ocw.mit.edu/6-0...
    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

КОМЕНТАРІ • 113

  • @freccia9500
    @freccia9500 6 років тому +235

    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

  • @trinhngocdieu
    @trinhngocdieu 2 роки тому +23

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

  • @neerajkrishna1983
    @neerajkrishna1983 3 роки тому +9

    Erik Demaine is one of the best Instructors!

  • @mohansinghrawat4324
    @mohansinghrawat4324 7 років тому +15

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

  • @hannahdo980
    @hannahdo980 3 роки тому +14

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

  • @LF58888
    @LF58888 Рік тому +14

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

    • @cosmic_gate476
      @cosmic_gate476 7 місяців тому +8

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

    • @LF58888
      @LF58888 7 місяців тому

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

  • @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 роки тому +11

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

  • @PeterHoward-r6p
    @PeterHoward-r6p 23 дні тому

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

  • @ryancocuzzo6322
    @ryancocuzzo6322 5 років тому +10

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

    • @aw6507
      @aw6507 2 роки тому

      yeah dude is a genius

  • @inadaizz
    @inadaizz 3 роки тому +2

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

  • @AshishKumar-zx6zz
    @AshishKumar-zx6zz 2 роки тому +1

    One of the best teachers

  • @eeee8677
    @eeee8677 6 років тому +48

    man I wish I went here );

  • @shivanshmishra752
    @shivanshmishra752 2 роки тому

    First time in my life loving the proofs

  • @TheKarateKidd
    @TheKarateKidd 4 роки тому +3

    This guy is a pro at writing on a chalkboard.

  • @Adi1995cv
    @Adi1995cv 7 років тому +3

    Perfect Textbook lecture. Thank you

  • @hemantdhanuka5919
    @hemantdhanuka5919 7 років тому +40

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

  • @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.

  • @fracturedude
    @fracturedude 6 років тому +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

  • @pourkavoosmedicalllcpourka7429

    What an excellent lecturer! Very clear and concise.

  • @AlexandrBorschchev
    @AlexandrBorschchev Рік тому

    Amazing instructor

  • @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 😂

  • @journeytowardslife9830
    @journeytowardslife9830 3 роки тому

    Erik is a genius !

  • @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!

  • @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.

  • @emanabdelhaleem7561
    @emanabdelhaleem7561 8 місяців тому

    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!

  • @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?

  • @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...

  • @inordirections
    @inordirections 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

  • @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.

  • @wolfinthesuit
    @wolfinthesuit 2 роки тому

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

  • @Loukas_Anastasiadis
    @Loukas_Anastasiadis 7 років тому +2

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

  • @niteeshchaturvedi2754
    @niteeshchaturvedi2754 6 років тому +3

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

  • @mtslr7378
    @mtslr7378 Рік тому

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

  • @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"

  • @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.

  • @ajinkyagaikwad5888
    @ajinkyagaikwad5888 4 роки тому

    awesome

  • @jonathanibarra8236
    @jonathanibarra8236 3 роки тому +3

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

  • @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

  • @3alabo
    @3alabo 3 роки тому

    this guy is so fucking awesome

  • @mostafasaadinasab6338
    @mostafasaadinasab6338 4 роки тому

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

  • @somerandomguy8361
    @somerandomguy8361 3 роки тому

    Where is recitation 3 lecture?

    • @mitocw
      @mitocw  3 роки тому

      Sorry, recitation 3 is not available.

  • @mons911
    @mons911 Рік тому

    I wanted to be on those benches! 💔

  • @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.

  • @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.

  • @shashwattyagi1417
    @shashwattyagi1417 3 роки тому +1

    17:30

  • @papetatedouces
    @papetatedouces 4 роки тому

    18:00 best way to contract an STD

  • @phangb580
    @phangb580 12 днів тому

    16:29

  • @maxyakovlev505
    @maxyakovlev505 6 років тому

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

  • @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

  • @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.

  • @RamshaRana
    @RamshaRana 7 років тому +1

    so cool (y)

  • @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!

  • @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

  • @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

  • @danielnzuma9070
    @danielnzuma9070 5 місяців тому

    Added this comment cause I cant like twice
    Thanks Eric

  • @meredithsui9532
    @meredithsui9532 4 роки тому

    confusing

  • @rachitrajput915
    @rachitrajput915 4 роки тому

    Itne saare black board.......

  • @shrimatkapoor2200
    @shrimatkapoor2200 4 роки тому +1

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

  • @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 !!!