{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lec0420-Graphs - Announcements MP 6 regrade window closes...

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

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)

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

View Full Document
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; } }
Analysis:

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

View Full Document
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? Name the last 4 data structures we’ve discussed: Which of those 4 is/are dictionaries? Give 2 applications of a Heap: What’s the buildHeap algorithm and how fast is it?
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

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

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

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

Dana University of Pennsylvania ‘17, Course Hero Intern

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

Jill Tulane University ‘16, Course Hero Intern