Docsity

MST: Skew Heaps, Decrease Key, Moving References, and Prim's Algorithm - Prof. David M. Mo, Study notes of Data Structures and Algorithms

Partial preview of the text

Download MST: Skew Heaps, Decrease Key, Moving References, and Prim's Algorithm - Prof. David M. Mo and more Study notes Data Structures and Algorithms in PDF only on Docsity!

Minimum Spanning

Trees

CMSC 420: Lecture 11

Following Dave Mount’s lecture in his lecture notes.

Skew Heaps

  • Self-adjusting version of leftist heaps
  • Don’t store^ npl^ (or any other auxiliary information at the nodes)
  • Difference : - always swap the left & right subtrees at each step of meld - old rightmost path becomes new leftmost path - Can show (beyond the scope of this class) that a series of m insert , findmin , meld operations take O( m log n ) time. - like splay trees, each operation takes O(log n) amortized time.

Handling Moving References

  • Problem : Suppose you have a heap and are also keeping pointers to objects stored in the heap (to use for delete & decrease_key )
  • When you sift up, nodes are going to move around, and the pointers will become invalid...
  • How would you solve this? 8 17 23 26 14 10 21 3 H p 1 p 2

Handling Moving References

  • Problem : Suppose you have a heap and are also keeping pointers to objects stored in the heap (to use for delete & decrease_key )
  • When you sift up, nodes are going to move around, and the pointers will become invalid...
  • How would you solve this? 8 17 23 26 14 10 21 3 H p 1 p 2

Spanning Trees

  • Given a graph G = (V,E)
  • A^ spanning tree^ is a connected, acyclic subset of edges that connects together all the vertices.
  • To connect all vertices with the fewest number of edges, it never makes sense to include a cycle.
  • If graph is^ weighed^ by putting real numbers on each edge, then we can look for a minimum cost spanning tree (called the minimum spanning tree )

Example – Spanning Trees

Example – Spanning Tree

Example Uses

  • Cable routing:^ connect houses with telephone or television cable.
  • Circuit Wiring:^ minimum amount of solder or heat.

Minimum Spanning Trees

Cost is 22

Minimum Spanning Trees

Cost is 22 There may be several MSTs

Example – Euclidian MST

Often vertices are embedded in plane and distance is Euclidian distance Example of metric MST

Cost of MST = 3

Example Metric Steiner Tree

If allowed to add points, then cost can be reduced. Example of metric Steiner Tree Cost = 2√2 = 2.

MST is fast!

  • MST is fast --- best is nearly linear.
  • But no known fast algorithms for Steiner tree (NP- hard)
  • How do we find the minimum spanning tree?

Cuts

  • A^ cut^ of a graph is a partition of its vertices into two groups.
  • Sometimes we refer to the edges that go from one group to another as the cut.
  • A edge {u,v} with u in S and v in V-S^ crosses^ the cut. S V - S