Transcript
Page 1: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

6 1 3

10 10 102 1 0

6 x 100+ 1 x 10 + 3 x 1

=613

Base 10

digits {0...9}

Base 10

digits {0...9}

Page 2: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

1 1 0 1

2 22 1 22 03

1 x 8+ 1 x 4+ 0 x 2+ 1 x 1

= 13

Base 2

digits {0, 1}

Base 2

digits {0, 1}

Page 3: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

decimal binary1 12 103 114 1005 1016 1107 1118 10009 100110 101011 101112 110013 110114 111015 1111

The binary equivalents of some decimal numbers.

The binary equivalents of some decimal numbers.

Page 4: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

parent

Left child right child

A binary tree consists of a set of nodes each of which can have at most two children.

A binary tree consists of a set of nodes each of which can have at most two children.

Page 5: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

root

leaf

leafleaf

The top node of the tree is called the root. A leaf is a node with no descendants.

The top node of the tree is called the root. A leaf is a node with no descendants.

Page 6: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

1 1 0 1

2 22 1 22 03

The binary digits (bits) in the computer’s memory are initially set to zero. To represent a number, the appropriate bits are set to 1.

The binary digits (bits) in the computer’s memory are initially set to zero. To represent a number, the appropriate bits are set to 1.

0 0 0 0

13 (dec)

Page 7: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

4 (dec) = Multiplying by 2 in machine language is accomplished by shifting left one bit.

Multiplying by 2 in machine language is accomplished by shifting left one bit.

000100

Page 8: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

4 (dec) =

8 (dec) =

Multiplying by 2 in machine language is accomplished by shifting left one bit.

Multiplying by 2 in machine language is accomplished by shifting left one bit.

000100

001000

Page 9: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

4 (dec) =

8 (dec) =

16 (dec) =

Multiplying by 2 in machine language is accomplished by shifting left one bit.

Multiplying by 2 in machine language is accomplished by shifting left one bit.

000100

001000

010000

Page 10: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

4 (dec) =

8 (dec) =

16 (dec) =

000100

001000

010000

5 (dec) =

9 (dec) =

17 (dec) =

000101

001001

010001

We obtain the next integer by adding a 1 to the binary number.

We obtain the next integer by adding a 1 to the binary number.

Page 11: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

n

2n 2n+1

Construct a tree using the following: If the parent ‘s node number is n, the left child’s is 2*n and the right child‘s is 2*n + 1.

Construct a tree using the following: If the parent ‘s node number is n, the left child’s is 2*n and the right child‘s is 2*n + 1.

Page 12: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

1

We assign 1 to the root’s node numberWe assign 1 to the root’s node number

Page 13: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

1

2

Then, the left child’s node number is 2Then, the left child’s node number is 2

Page 14: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

1

2 3

And the right child’s node number is 3.And the right child’s node number is 3.

Page 15: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

1

2 3

4 5 6 7

0

A graphical way of getting the binary equivalents of decimal numbers. Place a 0 on each left edge.

A graphical way of getting the binary equivalents of decimal numbers. Place a 0 on each left edge.

Page 16: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

1

2 3

4 5 6 7

0

0

A graphical way of getting the binary equivalents of decimal numbers. Place a 0 on each left edge.

A graphical way of getting the binary equivalents of decimal numbers. Place a 0 on each left edge.

Page 17: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

1

2 3

4 5 6 7

0

0 0

A graphical way of getting the binary equivalents of decimal numbers. Place a 0 on each left edge.

A graphical way of getting the binary equivalents of decimal numbers. Place a 0 on each left edge.

Page 18: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

1

2 3

4 5 6 7

0

0

1

0

A graphical way of getting the binary equivalents of decimal numbers. Place a 0 on each left edge and a 1 on each right edge of a binary tree.

A graphical way of getting the binary equivalents of decimal numbers. Place a 0 on each left edge and a 1 on each right edge of a binary tree.

Page 19: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

1

2 3

4 5 6 7

0

0 1

1

0

A graphical way of getting the binary equivalents of decimal numbers. Place a 0 on each left edge and a 1 on each right edge of a binary tree.

A graphical way of getting the binary equivalents of decimal numbers. Place a 0 on each left edge and a 1 on each right edge of a binary tree.

Page 20: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

1

2 3

4 5 6 7

0

0 1

1

10

A graphical way of getting the binary equivalents of decimal numbers. Place a 0 on each left edge and a 1 on each right edge of a binary tree.

A graphical way of getting the binary equivalents of decimal numbers. Place a 0 on each left edge and a 1 on each right edge of a binary tree.

Page 21: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

1

2 3

4 5 6 7

0

0

To convert 5 to binary, start by writing the lower-most 1 on the path from node 5 to the root.

To convert 5 to binary, start by writing the lower-most 1 on the path from node 5 to the root.

1

1

Page 22: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

1

2 3

4 5 6 7

0

0

To the left of the 1, write the digit for the next edge on the upward path to the root, namely, 0.

To the left of the 1, write the digit for the next edge on the upward path to the root, namely, 0.

1

01

Page 23: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

1

2 3

4 5 6 7

0

0

Finally, to the left of the 0, place a 1. This represents the node number of the root, 1, which is the same in binary and decimal.

Finally, to the left of the 0, place a 1. This represents the node number of the root, 1, which is the same in binary and decimal.

1

101

Page 24: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

1

2 3

4 5 6 7

0

0 1

1

10

100 101 110 111

The node numbers at the leaves converted to binary numbers.

The node numbers at the leaves converted to binary numbers.

Page 25: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

1

2 3

4 5 6 7

0

0 1

1

10

100 101 110 111

10 111

Placing a 0 on each left edge is equivalent to shifting left, ie., multiplying by 2. Placing a 1 on the right edge means you are adding 1 to the left child’s value.

Placing a 0 on each left edge is equivalent to shifting left, ie., multiplying by 2. Placing a 1 on the right edge means you are adding 1 to the left child’s value.

Page 26: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

67

33 1

Express 67 in decimalExpress 67 in decimal

1 (bin)

Page 27: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

67

33

16

1

1

11 (bin)

Page 28: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

67

33

16

8

1

1

0

011 (bin)

Page 29: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

67

33

16

8

4

1

1

0

0

0011 (bin)

Page 30: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

67

33

16

8

4

2

1

1

0

0

0

00011 (bin)

Page 31: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

67

33

16

8

4

2

1

1

1

0

0

0

0

000011 (bin)

Page 32: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

67

33

16

8

4

2

1

1

1

0

0

0

0

67 (dec) = 1000011 (bin)

Place 1 at the left since the root node contains 1.

Place 1 at the left since the root node contains 1.

Page 33: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

The ascii code in decimal and binary for some characters. Thus it requires 7 bits to represent each character.

The ascii code in decimal and binary for some characters. Thus it requires 7 bits to represent each character.

character ascii code binarya 97 1100001

b 98 1100010

c 99 1100011

d 100 1100100

e 101 1100101

f 102 1100110

g 103 1100111

h 104 1101000

i 105 1101001

j 106 1101010

k 107 1101011

l 108 1101100

m 109 1101101

n 110 1101110

American Standard Code for Information InterchangeAmerican Standard Code for Information Interchange

Page 34: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

a c

b

Symbol a: 00

0

1

Symbol b: 00

Symbol c : 1

The code 001 can be decoded as aac or bc. Thus the code is ambiguous.

The code 001 can be decoded as aac or bc. Thus the code is ambiguous.

Page 35: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

aSymbol a: 00

Symbol b: 01The code 01 is decoded as b. Before, however, you reach the end of the string 01, you would think that 0 corresponds to a. The code requires you to scan ahead. This is called non-instantaneous code and is inefficient as coding scheme.

The code 01 is decoded as b. Before, however, you reach the end of the string 01, you would think that 0 corresponds to a. The code requires you to scan ahead. This is called non-instantaneous code and is inefficient as coding scheme.

b

1

Page 36: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

a b

c

0

0

1

1

Symbol a: 00

Symbol b: 01

Symbol c: 1

If the characters are only in the leaves, the code is unique and instantaneous. Such a code exhibits the prefix property.

If the characters are only in the leaves, the code is unique and instantaneous. Such a code exhibits the prefix property.

Page 37: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

a b

c

0

0

1

1

Symbol a: 00

Symbol b: 01

Symbol c: 1

Let’s decode 10001Let’s decode 10001

Page 38: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

a b

c

0

0

1

1

Symbol a: 00

Symbol b: 01

Symbol c: 1

1000110001

Page 39: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

a b

c

0

0

1

1

Symbol a: 00

Symbol b: 01

Symbol c: 1

1000110001

cc

Page 40: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

a b

c

0

0

1

1

Symbol a: 00

Symbol b: 01

Symbol c: 1

1000110001

cc

Page 41: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

a b

c

0

0

1

1

Symbol a: 00

Symbol b: 01

Symbol c: 1

1000110001

cc

Page 42: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

a b

c

0

0

1

1

Symbol a: 00

Symbol b: 01

Symbol c: 1

1000110001

caca

Page 43: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

a b

c

0

0

1

1

Symbol a: 00

Symbol b: 01

Symbol c: 1

1000110001

caca

Page 44: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

a b

c

0

0

1

1

Symbol a: 00

Symbol b: 01

Symbol c: 1

1000110001

caca

Page 45: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

a b

c

0

0

1

1

Symbol a: 00

Symbol b: 01

Symbol c: 1

1000110001

cabcab

Page 46: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

Letter Frequencya 11b 2g 9h 4

Letters occurring in a paragraph and their frequency of occurrence. How can we encode these letters so that the resultant code is minimal?

Letters occurring in a paragraph and their frequency of occurrence. How can we encode these letters so that the resultant code is minimal?

Page 47: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

b, 2 h, 4 g, 9 a, 11

A list of nodes containing the letters and frequencies. The list is sorted by frequency.

A list of nodes containing the letters and frequencies. The list is sorted by frequency.

Page 48: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

b, 2 h, 4

g, 9 a, 11

Remove the first two nodes, add their frequencies, and create a parent node with that frequency. Letters will appear in only the leaves of the final tree.

Remove the first two nodes, add their frequencies, and create a parent node with that frequency. Letters will appear in only the leaves of the final tree.

*, 6

Page 49: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

b, 2 h, 4

g, 9 a, 11

Insert the parent node with its children in its sorted position in the list. This type of list and its operations is called a priority queue.

Insert the parent node with its children in its sorted position in the list. This type of list and its operations is called a priority queue.

*, 6

Page 50: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

b, 2 h, 4

g, 9

a, 11

*, 6

*, 15

Remove the first two nodes again, add their frequencies, and create a parent node with that frequency.

Remove the first two nodes again, add their frequencies, and create a parent node with that frequency.

Page 51: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

b, 2 h, 4

g, 9

a, 11

*, 6

*, 15

Insert the parent node with its children in its sorted position in the list.

Insert the parent node with its children in its sorted position in the list.

Page 52: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

b, 2 h, 4

g, 9

a, 11

*, 6

*, 15

By continuing the process, we get the final tree. The leaves are the only nodes containing letters.

By continuing the process, we get the final tree. The leaves are the only nodes containing letters.

*, 26

Page 53: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

b h

g

a

This tree is called a Huffman tree. Here it is shown with only the leaves labeled.

This tree is called a Huffman tree. Here it is shown with only the leaves labeled.

Page 54: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

b h

g

a

Label the edges with 0’s and 1’s as we did for the binary numbers.

Label the edges with 0’s and 1’s as we did for the binary numbers.

0

00

1

1

1

Page 55: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

b h

g

a

The letters with their Huffman codes. The letters with the higher frequencies have smaller Huffman codes.

The letters with their Huffman codes. The letters with the higher frequencies have smaller Huffman codes.

0

00

1

1

1

letter frequency Huffman codea 11 0g 9 11h 4 101b 2 100

Page 56: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

b h

g

a

Let’s decode 100011Let’s decode 100011

0

00

1

1

1

Page 57: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

b h

g

a

100011 100011

0

00

1

1

1

Page 58: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

b h

g

a

100011 100011

0

00

1

1

1

Page 59: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

b h

g

a

100011 100011

0

00

1

1

1

Page 60: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

b h

g

a

100011 We hit a leaf, print letter, 100011 We hit a leaf, print letter,

0

00

1

1

1

Resultant code: bResultant code: b

Page 61: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

b h

g

a

100011 We hit a leaf, print letter & return to root. 100011 We hit a leaf, print letter & return to root.

0

00

1

1

1

Resultant code: bResultant code: b

Page 62: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

b h

g

a

100011 We hit a leaf, print letter 100011 We hit a leaf, print letter

0

00

1

1

1

Resultant code: baResultant code: ba

Page 63: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

b h

g

a

100011 We hit a leaf, print letter & return to root. 100011 We hit a leaf, print letter & return to root.

0

00

1

1

1

Resultant code: baResultant code: ba

Page 64: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

b h

g

a

100011 100011

0

00

1

1

1

Resultant code: baResultant code: ba

Page 65: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

b h

g

a

100011 We hit a leaf and print letter. 100011 We hit a leaf and print letter.

0

00

1

1

1

Resultant code: bagResultant code: bag

Page 66: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

bag : 100011 in Huffman code

bag : 1100010

bag : 100011 in Huffman code

bag : 1100010

character ascii code binarya 97 1100001

b 98 1100010

c 99 1100011

d 100 1100100

e 101 1100101

f 102 1100110

g 103 1100111

h 104 1101000

i 105 1101001

j 106 1101010

k 107 1101011

l 108 1101100

m 109 1101101

n 110 1101110

Page 67: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

bag : 100011 in Huffman code

bag : 11000101100001

bag : 100011 in Huffman code

bag : 11000101100001

character ascii code binarya 97 1100001

b 98 1100010

c 99 1100011

d 100 1100100

e 101 1100101

f 102 1100110

g 103 1100111

h 104 1101000

i 105 1101001

j 106 1101010

k 107 1101011

l 108 1101100

m 109 1101101

n 110 1101110

Page 68: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

bag : 100011 in Huffman code

bag : 110001011000011100111 in ascii code

bag : 100011 in Huffman code

bag : 110001011000011100111 in ascii code

character ascii code binarya 97 1100001

b 98 1100010

c 99 1100011

d 100 1100100

e 101 1100101

f 102 1100110

g 103 1100111

h 104 1101000

i 105 1101001

j 106 1101010

k 107 1101011

l 108 1101100

m 109 1101101

n 110 1101110

Page 69: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

12,b 13,h

7,g

2,a

If you number the nodes as we did when we converted decimal to binary, you can get the Huffman code from the node numbers.

If you number the nodes as we did when we converted decimal to binary, you can get the Huffman code from the node numbers.

Page 70: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

12,b 13,h

7,g

2,a

Letter Node Binary Huffman Codea 2 10 0g 7 111 11h 13 1101 101b 12 1100 100

The Huffman code is obtained from the binary by removing the leading 1.

The Huffman code is obtained from the binary by removing the leading 1.

Page 71: 6 1 3 10 10 10 2 1 0 6 x 100+ 1 x 10 + 3 x 1 =613 Base 10 digits {0...9} Base 10 digits {0...9}

"Baseball's Sad Lexicon"

These are the saddest of possible words: "Tinker to Evers to Chance." Trio of bear cubs, and fleeter than birds, Tinker and Evers and Chance. Ruthlessly pricking our gonfalon bubble, Making a Giant hit into a double-- Words that are heavy with nothing but trouble: "Tinker to Evers to Chance." Franklin Pierce Adams

http://memory.loc.gov/ammem/bbhtml/bb1.html


Top Related