{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

chap21-solutions

chap21-solutions - Selected Solutions for Chapter 21 Data...

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

Selected Solutions for Chapter 21: Data Structures for Disjoint Sets Solution to Exercise 21.2-3 We want to show that we can assign O.1/ charges to M AKE -S ET and F IND -S ET and an O. lg n/ charge to U NION such that the charges for a sequence of these operations are enough to cover the cost of the sequence— O.m C n lg n/ , according to the theorem. When talking about the charge for each kind of operation, it is helpful to also be able to talk about the number of each kind of operation. Consider the usual sequence of m M AKE -S ET , U NION , and F IND -S ET operations, n of which are M AKE -S ET operations, and let l < n be the number of U NION operations. (Recall the discussion in Section 21.1 about there being at most n NUL 1 U NION operations.) Then there are n M AKE -S ET operations, l U NION operations, and m NUL n NUL l F IND -S ET operations. The theorem didn’t separately name the number l of U NION s; rather, it bounded the number by n . If you go through the proof of the theorem with l U NION s, you

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 2

chap21-solutions - Selected Solutions for Chapter 21 Data...

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

View Full Document
Ask a homework question - tutors are online