Chapter 5: Q13E (page 162)
A long string consists of the four characters ; they appear with frequency and respectively. What is the Huffman encoding of these four characters?
Short Answer
Huffman encoding of the characters is respectively.
Chapter 5: Q13E (page 162)
A long string consists of the four characters ; they appear with frequency and respectively. What is the Huffman encoding of these four characters?
Huffman encoding of the characters is respectively.
All the tools & learning materials you need for study success - in one app.
Get started for freeLet be an undirected graph. Prove that if all its edge weights are distinct, then it has a unique minimum spanning tree
Give a linear-time algorithm that takes as input a tree and determines whether it has a perfect matching: a set of edges that touches each node exactly once.
A feedback edge set of an undirected graph G(V,E) is a subset of edgesthat intersects every cycle of the graph. Thus, removing the edges will render the graph acyclic.
Give an efficient algorithm for the following problem:
Input: Undirected graph G(V,E) with positive edge weights .
Output: A feedback edge set minimum total weight .
Consider an undirected graph with nonnegative edge weights role="math" localid="1658915178951" . Suppose that you have computed a minimum spanning tree of G, and that you have also computed shortest paths to all nodes from a particular node role="math" localid="1658915296891" . Now suppose each edge weight is increased by 1: the new weights are .
(a) Does the minimum spanning tree change? Give an example where it changes or prove it cannot change.
(b) Do the shortest paths change? Give an example where they change or prove they cannot change.
Suppose we want to find the minimum spanning tree of the following graph.
(a) Run Prim’s algorithm; whenever there is a choice of nodes, always use alphabetic ordering (e.g., start from node A). Draw a table showing the intermediate values of the cost array.
(b) Run Kruskal’s algorithm on the same graph. Show how the disjoint-sets data structure looks at every intermediate stage (including the structure of the directed trees), assuming path compression is used.
Entropy: Consider a distribution overpossible outcomes, with probabilities .
a. Just for this part of the problem, assume that each is a power of 2 (that is, of the form ). Suppose a long sequence of samples is drawn from the distribution and that for all , the outcome occurs exactly times in the sequence. Show that if Huffman encoding is applied to this sequence, the resulting encoding will have length
b. Now consider arbitrary distributions-that is, the probabilities are noy restricted to powers of 2. The most commonly used measure of the amount of randomness in the distribution is the entropy.
For what distribution (over outcomes) is the entropy the largest possible? The smallest possible?
What do you think about this solution?
We value your feedback to improve our textbook solutions.