lec0418-DS - Announcements: MP 6 regrade window extended...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Announcements: MP 6 regrade window extended indefinitely. Late penalty waived. MP7 available. Due soon. Start now. Today: Disjoint Sets A Disjoint Sets example: Let R be an equivalence relation on the set of students in this room, where (s,t) R if s and t have the same favorite among {AB, FN, DJ, ZH, PvZ}. 0 1 4 8 2 5 9 3 6 7 1. Find(4) 2. Find(4)==Find(8) 3. If (!(Find(7)==Find(2)) then Union(Find(7),Find(2))
Background image of page 1

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

View Full DocumentRight Arrow Icon
Disjoint Sets ADT We will implement a data structure in support of “Disjoint Sets”: Maintains a collection S = {s 0 , s 1 , … s k } of disjoint sets. Each set has a representative member. Supports functions: A first data structure for Disjoint Sets: Find: Union: void MakeSet(const T & k); void Union(const T & k1, const T & k2); T & Find(const T & k);
Background image of page 2
1 2 3 0 1 2 3 0 1 2 3 A better data structure for Disjoint Sets: UpTrees • if array value is -1, then we’ve found a root, o/w value is index of parent. • x and y are in the same tree iff they are in the same set.
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 12

lec0418-DS - Announcements: MP 6 regrade window extended...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online