1 / 71

6 1 3

2 1 0. 10 10 10. Base 10 digits {0...9}. 6 1 3. 6 x 100+ 1 x 10 + 3 x 1. =613. Base 2 digits {0, 1}. 3. 2. 1. 0. 2. 2. 2. 2. 1 1 0 1. 1 x 8+ 1 x 4+ 0 x 2+ 1 x 1. = 13.

angelo
Download Presentation

6 1 3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. Base 2 digits {0, 1} 3 2 1 0 2 2 2 2 1 1 0 1 1 x 8+ 1 x 4+ 0 x 2+ 1 x 1 = 13

  3. The binary equivalents of some decimal numbers.

  4. A binary tree consists of a set of nodes each of which can have at most two children. parent Left child right child

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

  6. 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 3 2 1 0 2 2 2 2 1 1 0 1 13 (dec)

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

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

  9. 4 (dec) = 000100 Multiplying by 2 in machine language is accomplished by shifting left one bit. 8 (dec) = 001000 16 (dec) = 010000

  10. 4 (dec) = 000100 5 (dec) = 000101 We obtain the next integer by adding a 1 to the binary number. 8 (dec) = 001000 9 (dec) = 001001 16 (dec) = 010000 17 (dec) = 010001

  11. 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.

  12. 1 We assign 1 to the root’s node number

  13. 1 2 Then, the left child’s node number is 2

  14. 1 3 2 And the right child’s node number is 3.

  15. 1 0 2 3 4 5 6 7 A graphical way of getting the binary equivalents of decimal numbers. Place a 0 on each left edge.

  16. 1 0 2 3 0 4 5 6 7 A graphical way of getting the binary equivalents of decimal numbers. Place a 0 on each left edge.

  17. 1 0 2 3 0 0 4 5 6 7 A graphical way of getting the binary equivalents of decimal numbers. Place a 0 on each left edge.

  18. 1 1 0 2 3 0 0 4 5 6 7 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.

  19. 1 1 0 2 3 1 0 0 4 5 6 7 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.

  20. 1 1 0 2 3 1 0 1 0 4 5 6 7 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.

  21. 1 0 2 3 0 1 4 5 6 7 1 To convert 5 to binary, start by writing the lower-most 1 on the path from node 5 to the root.

  22. 1 0 2 3 0 1 4 5 6 7 01 To the left of the 1, write the digit for the next edge on the upward path to the root, namely, 0.

  23. 1 0 2 3 0 1 4 5 6 7 101 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.

  24. 1 1 0 2 3 1 0 1 0 4 5 6 7 100 101 110 111 The node numbers at the leaves converted to binary numbers.

  25. 1 1 0 1 2 3 10 11 1 0 1 0 4 5 6 7 100 101 110 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.

  26. Express 67 in decimal 33 1 (bin) 1 67

  27. 16 1 33 11 (bin) 1 67

  28. 8 0 16 1 33 011 (bin) 1 67

  29. 4 0 8 0 16 1 33 0011 (bin) 1 67

  30. 2 0 4 0 8 0 16 1 33 00011 (bin) 1 67

  31. 1 0 2 0 4 0 8 0 16 1 33 000011 (bin) 1 67

  32. 1 0 Place 1 at the left since the root node contains 1. 2 0 4 0 8 0 16 1 33 67 (dec) = 1000011 (bin) 1 67

  33. American Standard Code for Information Interchange The ascii code in decimal and binary for some characters. Thus it requires 7 bits to represent each character.

  34. 0 1 Symbol a: 0 The code 001 can be decoded as aac or bc. Thus the code is ambiguous. c a Symbol b: 00 0 Symbol c : 1 b

  35. 0 Symbol a: 0 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. a Symbol b: 01 1 b

  36. If the characters are only in the leaves, the code is unique and instantaneous. Such a code exhibits the prefix property. 0 1 Symbol a: 00 c Symbol b: 01 1 0 a Symbol c: 1 b

  37. Let’s decode 10001 0 1 Symbol a: 00 c Symbol b: 01 1 0 a Symbol c: 1 b

  38. 10001 0 1 Symbol a: 00 c Symbol b: 01 1 0 a Symbol c: 1 b

  39. 10001 c 0 1 Symbol a: 00 c Symbol b: 01 1 0 a Symbol c: 1 b

  40. 10001 c 0 1 Symbol a: 00 c Symbol b: 01 1 0 a Symbol c: 1 b

  41. 10001 c 0 1 Symbol a: 00 c Symbol b: 01 1 0 a Symbol c: 1 b

  42. 10001 ca 0 1 Symbol a: 00 c Symbol b: 01 1 0 a Symbol c: 1 b

  43. 10001 ca 0 1 Symbol a: 00 c Symbol b: 01 1 0 a Symbol c: 1 b

  44. 10001 ca 0 1 Symbol a: 00 c Symbol b: 01 1 0 a Symbol c: 1 b

  45. 10001 cab 0 1 Symbol a: 00 c Symbol b: 01 1 0 a Symbol c: 1 b

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

  47. A list of nodes containing the letters and frequencies. The list is sorted by frequency. b, 2 h, 4 g, 9 a, 11

  48. 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 g, 9 a, 11 b, 2 h, 4

  49. 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 g, 9 a, 11 b, 2 h, 4

  50. Remove the first two nodes again, add their frequencies, and create a parent node with that frequency. *, 15 a, 11 *, 6 g, 9 b, 2 h, 4

More Related