Method incidentedges is called once for each vertex

Info icon This preview shows pages 15–17. Sign up to view the full content.

View Full Document Right Arrow Icon
Method incidentEdges is called once for each vertex Label operations We set/get the distance, parent and locator labels of vertex  z   O (deg( z ))   times Setting/getting a label takes  O (1)  time Priority queue operations Each vertex is inserted once into and removed once from the priority  queue, where each insertion or removal takes  O (log n ) time The key of a vertex  w  in the priority queue is modified at most  deg( w ) times, where each key change takes  O (log n ) time  Prim-Jarnik’s algorithm runs in  O (( n + m ) log n )  time provided the  graph is represented by the adjacency list structure Recall that  Σ v deg( v ) = 2 m The running time is  O ( m log n )  since the graph is connected
Image of page 15

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
©  2010 Goodrich, Tamassia Minimum Spanning Trees 16 Baruvka’s Algorithm (Exercise) Like Kruskal’s Algorithm, Baruvka’s algorithm grows many  clusters at once and maintains a forest  T Each iteration of the while loop halves the number of connected  components in forest  T The running time is  O ( m log n ) Algorithm BaruvkaMST ( G ) T V {just the vertices of G } while T has fewer than n - 1 edges do for each connected component C in T do Let edge e be the smallest-weight edge from C to another component in T if e is not already in T then Add edge e to T return T
Image of page 16
©  2010 Goodrich, Tamassia Example of Baruvka’s  Algorithm (animated) CSC 316 17 1 5 4 3 2 3 4 4 9 6 8 7 6 5 4 9 6 8 Slide by Matt Stallmann  included with permission. Slide by Matt Stallmann  included with permission. 1 5 4 3 2 3 4 4 9 6 8 7 6 5
Image of page 17
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern