/*! This file is auto-generated */ .wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em}.wp-block-file__button{background:#32373c;color:#fff;text-decoration:none} Q11E Give the state of the disjoint-s... [FREE SOLUTION] | 91Ó°ÊÓ

91Ó°ÊÓ

Give the state of the disjoint-sets data structure after the following sequence of operations, starting from singleton sets 1,…,8. Usepath compression. In the case of ties, always make the lower numbered root point to the higher numbered ones.

union1,2,union3,4,union5,6,union7,8

,union1,4,union6,7,union4,5,find1

Short Answer

Expert verified

The state of the disjoint-sets data structure using path compression.

Step by step solution

01

Explain the data structure for disjoint sets. 

Disjoint sets can be stored as the directed tree arranged in no particular order.

Parent pointer π and rank are the components of the disjoint set data structure. The union of the disjoint set from the singleton sets can be done by the path compression method.

02

Step 2:Give the state of the disjoint-sets data structure using path compression. 

Consider the properties to perform union of the sets.

Property 1: For rankx<rankπx, Create a root node with rank K by merging the two trees with roots of rank k-1 .

Property 2: Any root node of rank K has at least 2knodes in its tree.

Property 3: If there are n elements overall, there can be at most n2k nodes of rank .

Consider the singleton sets 1,…,8. Represent the singleton sets as the nodes with the rank 0 .

Perform ,by using properties.

The node with the lowest number points to the highest number, and the number of nodes or subtrees are represented as degree.

Perform union1,4as follows,

The node 4 has two sub nodes, the degree of the node is updated as 2.

Perform union6,7

By the property 1, node 6 points to the node7 and the degree of the 7 is updated to 2 and the degree of 8 is updated to 3.

Perform union4,5

By the property 1, the node 4 points to 5 and the degrees of node 6,7, and 8 are updated accordingly. The tree has now has the root with larger degree, by applying properties 1 and 2 , merge the tree as follows.

Perform find(1),

Disassociate the nodes with the highest degrees and make them pointed to the higher numbered root as follows.

Therefore, the state of disjoint set data structure is found by the path compression method

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with 91Ó°ÊÓ!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

Let T be an MST of graph G. Given a connected subgraph H of G, show that T∩H is contained in some MST of H

Show how to find the maximum spanning tree of a graph, that is , the spanning tree of largest total weight.

The following statements may or may not be correct, In each case, either prove it (if it is correct) or give a counter-example (if it isn’t correct). Always assume that the graph G=(V,E)is undirected. Do not assume that edge weights are distinct unless this is specifically stated.

  1. If a graph G has more than |V|-1edges, and there is a unique heaviest edge, then this edge cannot be part of a minimum spanning tree.
  2. If G has a cycle with a unique heaviest edge e, then e cannot be part of any MST.
  3. Let e be any edge of minimum weight in G. Then e must be part of some MST.
  4. If the lightest edge in a graph is unique, then it must be part of every MST.
  5. If e is part of some MST of G, then it must be a lightest edge across some cut of .
  6. If G has a cycle with a unique lightest edge e must be part of every MST.
  7. The shortest-path tree computed by Dijkstra’s algorithm is necessarily an MST.
  8. The shortest path between two nodes is necessarily part of some MST.
  9. Prim’s algorithm works correctly when there are negative edges.
  10. (For any r>0, define an r-path to be a path whose edges all have weight <r). If G contains an r-path from node s to t , then every MST of G must also contain an r-path from node s to node t.

Design a linear-time algorithm for the following task.

Input: A connected, undirected graphG.

Question:Is there an edge you can remove fromGwhile still leavingGconnected?

Can you reduce the running time of your algorithm toO(V)?

Suppose you implement the disjoint-sets data structure usingunion-by-rank but not path compression. Give a sequence ofm union and find operations onnelements that take Ω(mlogn)time.

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.