Suppose that you want to add an extra operation deunion


Question: Suppose that you want to add an extra operation, deunion, which undoes the last union operation not already undone. One way to do so is to use union-by-rank-but a compression less find-and use a stack to store the old state prior to a union. A deunion can be implemented by popping the stack to retrieve an old state.

a. Why can't we use path compression?

b. Implement the union/find/deunion algorithm.

Solution Preview :

Prepared by a verified Expert
Data Structure & Algorithms: Suppose that you want to add an extra operation deunion
Reference No:- TGS02462802

Now Priced at $20 (50% Discount)

Recommended (90%)

Rated (4.3/5)