Lec0420-Graphs - Announcements MP 6 regrade window closes tonight 11:59p Late penalty waived MP7 available Due soon Start now Today graphs but

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

View Full Document Right Arrow Icon
10 9 11 1 7 2 8 4 3 5 6 Announcements: MP 6 regrade window closes tonight, 11:59p. Late penalty waived. MP7 available. Due soon. Start now. Today: graphs, but first… Path Compression: Disjoint Sets ADT: U_______, F_______ _______ _______ (running times)
Background image of page 1

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

View Full DocumentRight Arrow Icon
Path Compression: int DS::Find(int i) { if (s[i] < 0) return i; else return Find(s[i]); } void DS::UnionBySize(int root1, int root2) { int newSize = s[root1]+s[root2]; if (isBigger(root1,root2)) { s[root2]= root1; s[root1]= newSize; } else { s[root1] = root2; s[root2]= newSize; } }
Background image of page 2
Analysis:
Background image of page 3

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

View Full DocumentRight Arrow Icon
A B C D E F If (Find(A) != Find(B) Union(Find(A),Find(B)); If (Find(D) != Find(E) Union(Find(D),Find(E)); If (Find(A) != Find(C) Union(Find(A),Find(C)); If (Find(C) != Find(B) Union(Find(C),Find(B)); If (Find(B) != Find(F)) Union(Find(B),Find(F)); If (Find(D) != Find(F)) Union(Find(D),Find(F)); Trace the code below. Use Path Compression, Union by Height, and a pencil. What’s the tree height of the final tree?
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/26/2012 for the course CS CS 225 taught by Professor Heeren during the Spring '09 term at University of Illinois, Urbana Champaign.

Page1 / 23

Lec0420-Graphs - Announcements MP 6 regrade window closes tonight 11:59p Late penalty waived MP7 available Due soon Start now Today graphs but

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

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