0% found this document useful (0 votes)
20 views7 pages

DC Mid Material

The document provides detailed answers to several questions related to information theory, including entropy, coding methods, and unique decodability. It includes step-by-step calculations for entropy and Huffman coding, as well as explanations of concepts like distortion and adaptive Huffman encoding. The answers are structured with rewritten questions followed by comprehensive responses, demonstrating the application of theoretical concepts in practical scenarios.

Uploaded by

SUTARIYA TULASI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views7 pages

DC Mid Material

The document provides detailed answers to several questions related to information theory, including entropy, coding methods, and unique decodability. It includes step-by-step calculations for entropy and Huffman coding, as well as explanations of concepts like distortion and adaptive Huffman encoding. The answers are structured with rewritten questions followed by comprehensive responses, demonstrating the application of theoretical concepts in practical scenarios.

Uploaded by

SUTARIYA TULASI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

give me all the answer with re-write the question and write step by step in non-theory questions

answer and write detailed descriptive question where ask about description

Great—here are complete, clean answers for every item you shared. I’ve rewritten each question first,
then provided the answer. Wherever a calculation or check is involved, I’ve shown it step-by-step;
wherever a description is asked, I’ve written a concise but detailed explanation.

Q1 (a)
Question (rewritten)

Explain how modeling and coding can reduce the rate using the following data:
9, 11, 11, 11, 14, 13, 15, 17, 16, 17, 20, 21.

Answer (step-by-step)

Goal: Show that (i) a simple source model lowers entropy, and (ii) an entropy code then lowers the
average bits/symbol.
Step 1 – Entropy of the raw data
Frequencies (12 samples):

Symbol Count Probability

9 1 1/12 ≈ 0.0833

11 3 3/12 = 0.25
13 1 0.0833

14 1 0.0833

15 1 0.0833

16 1 0.0833

17 2 2/12 ≈ 0.1667
20 1 0.0833

21 1 0.0833

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 1/7
Raw entropy
Hraw = − ∑ p(x) log2 p(x) ≈ 3.022 bits/symbol.
​ ​

(With a fixed-length binary code for values 0–31 you’d spend 5 bits/symbol; a Huffman code here would
be ≈3.08 bits/symbol.)

Step 2 – Modeling via first-order prediction (delta coding)


Keep the first sample as is; encode differences thereafter:
Data: 9, 11, 11, 11, 14, 13, 15, 17, 16, 17, 20, 21
Differences: +2, 0, 0, +3, −1, +2, +2, −1, +1, +3, +1

Counts over the 11 differences:

Diff Count Probability


−1 2 2/11 ≈ 0.1818

0 2 0.1818

+1 2 0.1818

+2 3 3/11 ≈ 0.2727
+3 2 0.1818

Entropy of differences
HΔ ≈ 2.300 bits/difference (lower than 3.022).

Step 3 – Coding (Huffman on the differences)


A valid Huffman code for the differences is:

Symbol Code Length


+2 10 2

−1 00 2
0 01 2
+3 110 3

+1 111 3

Average length on differences


LΔ = 0.2727⋅ 2 + 4⋅ 0.1818⋅ (2 or 3) ≈ 2.364 bits/diff.

Step 4 – Put it together

First sample (raw): use 5 bits (covering 0–31).


Remaining 11 samples: ≈ 11 × 2.364 = 26.00 bits.

Total ≈ 5 + 26.00 = 31.00 bits for 12 samples →


Average ≈ 31.00/12 = 2.58 bits/symbol.
Conclusion: Modeling (delta) reduced entropy (3.022 → 2.300), and coding (Huffman) brought the
practical rate down to ≈ 2.58 bits/symbol, a large gain vs both fixed-length (5 bits) and raw-Huffman
(~3.08 bits).

Q1 (b)
Question (rewritten)
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 2/7
Define Entropy and Distortion.

Answer (descriptive)

Entropy (H): The theoretical lower bound (in bits per symbol) on the average number of bits
needed to losslessly represent outcomes of a random source. For discrete X with pmf p(x),
H(X) = − ∑x p(x) log2 p(x). Higher uncertainty ⇒ higher entropy.
​ ​

Distortion (D): A numerical measure of the loss in fidelity between original data x and its
^ after lossy compression. It is defined through a distortion measure d(x, x
reproduction x ^) (e.g.,
^ )]. Lower distortion ⇒ better
mean squared error, absolute error). Average distortion is E[d(X, X
reconstruction quality.

Q1 (c)
Question (rewritten)

Check whether the following code set is uniquely decodable:


{ 0, 01, 11, 111 }.

Answer (step-by-step, Sardinas–Patterson test)

Let C = {0, 01, 11, 111}. Build sets Uk .

U1 : all non-empty suffixes from overlaps among codewords.


Pairs where one is a prefix of the other:


0 is a prefix of 01 → suffix 1
11 is a prefix of 111 → suffix 1
So U1 = {1}.

U2 from U1 vs C :
​ ​

For u = 1:

1 is a prefix of 11 → suffix 1
1 is a prefix of 111 → suffix 11
No codeword is a prefix of 1.
Hence U2 = {1, 11}.

U3 from U2 vs C :
​ ​

For u = 1: as above → {1, 11}.


For u = 11: 11 is a prefix of 111 → suffix 1.
Thus U3 = {1, 11} (same as U2 ).
​ ​

Because the sets repeat and no empty string appears in any Uk , the code is uniquely decodable

(though it is not prefix-free because 0 prefixes 01).

Q1 (d)
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 3/7
Question (rewritten)

Explain the method of checking a prefix code using a prefix tree (trie).

Answer (descriptive)

To verify that a code is prefix-free (instantaneous) using a prefix tree:

1. Build a binary trie: Start from the root. For each codeword, follow edges bit-by-bit (0 = left, 1 =
right), creating nodes as needed.
2. Mark terminals: When a codeword ends, mark that node as a leaf (terminal).
3. Check the prefix condition:

If you ever try to extend past a terminal (i.e., a terminal node has children), then that earlier
codeword is a prefix of a longer one ⇒ not prefix-free.
If two codewords end at the same node, they are identical (invalid duplication).
4. Decision: If every codeword ends at a leaf and no terminal has children, the set is prefix-free.

This check is linear in the total number of bits across all codewords and is the standard way to validate
instantaneous decodability.

Q2 (Attempt any two)

Q2 (a)
Question (rewritten)

A source emits letters from the alphabet {a, b, c, d, e} with probabilities


P = {0.15, 0.04, 0.26, 0.05, 0.50} respectively.
Calculate: (1) the entropy and (2) a Huffman code.

Answer (step-by-step)

(1) Entropy

H = − ∑ p log2 p ​

= −(0.50 log2 0.50 + 0.26 log2 0.26 + 0.15 log2 0.15


​ ​ ​

+ 0.05 log2 0.05 + 0.04 log2 0.04)


​ ​

​ ​

≈ 1.818 bits/symbol.

(2) Huffman coding (merging smallest probabilities first)


Initial weights:
b : 0.04, d : 0.05, a : 0.15, c : 0.26, e : 0.50
Merges:

1. b(0.04) + d(0.05) = 0.09


Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 4/7
2. 0.09 + a(0.15) = 0.24
3. 0.24 + c(0.26) = 0.50
4. 0.50 + e(0.50) = 1.00 (root)

Assigning bits (shortest to most probable):

e→0
Split 0.50 on the right: c → 11, and the 0.24 node → 10
Split 0.24: a → 101, and the 0.09 node → 100
Split 0.09: d → 1001, b → 1000

Code & lengths

Symbol Code Length


e (0.50) 0 1

c (0.26) 11 2
a (0.15) 101 3
d (0.05) 1001 4
b (0.04) 1000 4

Average length:
L = 0.50⋅ 1 + 0.26⋅ 2 + 0.15⋅ 3 + 0.05⋅ 4 + 0.04⋅ 4 = 1.83 bits/symbol.
Efficiency: η = H/L ≈ 1.818/1.83 ≈ 99.33%.
(So the code is very close to the entropy bound.)

Q2 (b)
Question (rewritten)

How is the remainder coded in Golomb coding (rules)? Generate the Golomb code for parameter m =
5 for integers n = 0 to 7.

Answer (descriptive + step-by-step)

Golomb coding rules (parameter m)


For an integer n ≥ 0:

1. Compute quotient q = ⌊n/m⌋ and remainder r = n mod m.


2. Encode q in unary: q ones followed by a zero.

3. Encode r using a truncated binary code:

Let b = ⌈log2 m⌉ and t = 2b − m.


If r < t, send r in b − 1 bits.


Else, send r + t in b bits.

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 5/7
Apply to m =5
b = ⌈log2 5⌉ = 3, t = 23 − 5 = 3.

Remainder coding:

r = 0, 1, 2 (<3) → 2 bits: 00, 01, 10.


r = 3, 4 (≥3) → map to r + t = 6, 7 → 3 bits: 110, 111.

Now, for each n:

n q = ⌊n/5⌋ r = n mod 5 Unary for q Truncated-binary for r Golomb code

0 0 0 0 00 000
1 0 1 0 01 001
2 0 2 0 10 010
3 0 3 0 110 0110
4 0 4 0 111 0111

5 1 0 10 00 1000
6 1 1 10 01 1001
7 1 2 10 10 1010

(You can continue similarly for larger n.)

Q2 (c)
Question (rewritten)

Explain Generic Adaptive Huffman encoding and decoding rules.

Answer (descriptive)

What it is: Adaptive (dynamic) Huffman coding compresses data on the fly without a prior pass to
estimate symbol probabilities. The code changes as statistics evolve, while keeping encoder and decoder
synchronized.

Core ideas (FGK/Vitter-style “generic” adaptive rules):

1. Start with an empty model consisting of a special NYT (“Not Yet Transmitted”) leaf and weight 0 for
all nodes.

2. Encoding a symbol x:

If x has not appeared before:


a) Output the codeword for NYT (its current path).
b) Then output a fixed representation of x (e.g., its 8-bit ASCII).
c) Insert a new leaf for x and a new NYT as its sibling.

If x has appeared: output the current codeword for leaf x.

3. Update after each symbol (the “sibling property”):

Increment the weight of leaf x by 1.

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 6/7
While moving up to the root, maintain the sibling property: in each weight class, nodes are
arranged so that all nodes with the same weight form a contiguous block and each node’s
order index is greater than any node in its subtree.

If needed, swap the current node with the highest-order node in its weight class (that is not
its ancestor).

After any swap, increment the parent’s weight and continue upward until the root’s weight
increases by 1.
4. Decoding mirrors encoding:
The decoder maintains the same tree.

When it reads a codeword:

If it decodes the NYT, it reads the next fixed-length bits to get the new symbol, creates the
same new leaf/NYT structure, then performs the same updates.

Otherwise, it outputs the decoded leaf symbol and performs the same weight
updates/swaps.
5. Properties:

Instantaneous decoding at every step (prefix codes).

No separate header or prepass required.


Adapts to nonstationary sources; early performance may be suboptimal but converges as
statistics stabilize.

(Optional) Quick pointers to earn full marks


In Q1(a), explicitly state both numbers: entropy before (≈3.022) and after modeling (≈2.300), and
the achieved average with coding (≈2.58 bits/symbol).
In Q1(c), show U1 , U2 , U3 clearly and note that no empty string appears.
​ ​ ​

In Q2(b), show the truncated-binary split using b = ⌈log2 m⌉ and t = 2b − m.


In Q2(c), mention NYT, sibling property, and node swapping; that’s what graders look for.

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 7/7

You might also like