/*! 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<rankx, 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

A binary counter of unspecified length supports two operations: increment (which increases its value by one) and reset (which sets its value back to zero). Show that, starting from an initially zero counter, any sequence of n increment and reset operations takes time O(n); that is, the amortized time per operation is O(1) .

Show that for any integer n that is a power of 2 , there is an instance of the set cover problem (Section 5.4) with the following properties:

  1. There are n elements in the base set.
  2. The optimal cover uses just two sets.
  3. The greedy algorithm picks at least log n sets.

Thus the approximation ratio we derived in the chapter is tight.

The following table gives the frequencies of the letters of the English language (including the blank for separating words) in a particular corpus.

blank

18.3%

r

4.8%

y

1.6%

e

10.2%

d

3.5%

p

1.6%

t

7.7%

l

3.4%

b

1.3%

a

6.8%

c

2.6%

v

0.9%

o

5.9%

u

2.4%

k

0.6%

i

5.8%

m

2.1%

j

0.2%

n

5.5%

w

1.9%

x

0.2%

s

5.1%

f

1.8%

q

0.1%

h

4.9%

g

1.7%

z

0.1%

  1. What is the optimum Huffman encoding of this alphabet?
  2. What is the expected number of bits per letter?
  3. Suppose now that we calculate the entropy of these frequencies

H=t=026ptlog1pt

(see the box in page 143). Would you expect it to be larger or smaller than your answer above? Explain.

d. Do you think that this is the limit of how much English text can be compressed? What features of the English language, besides letters and their frequencies, should a better compression scheme take into account?

Ternary Huffman. Trimedia Disks Inc. has developed 鈥渢ernary鈥 hard disks. Each cell on a disk can now store values 0,1, or 2(instead of just 0 or 1). To take advantage of this new technology, provide a modified Huffman algorithm for compressing sequences of characters from an alphabet of size n, where the characters occur with known frequencies f1, f2,...., fn. Your algorithm should encode each character with a variable-length codeword over the values 0,1,2, such that no codeword is a prefix of another codeword and so as to obtain the maximum possible compression. Prove that your algorithm is correct

Let G=(V,E) be an undirected graph. Prove that if all its edge weights are distinct, then it has a unique minimum spanning tree

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.