1 / 27

Graph Theory in Computer Science

Greg Stoll November 22, 2008. Graph Theory in Computer Science. Graph colorings Huffman encoding. Today's Topics . Graph colorings. Graph colorings. What's the fewest number of colors that are needed to color a given graph?. Graph colorings.

henning
Download Presentation

Graph Theory in Computer Science

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. Greg Stoll November 22, 2008 Graph Theory in Computer Science

  2. Graph colorings Huffman encoding Today's Topics

  3. Graph colorings

  4. Graph colorings

  5. What's the fewest number of colors that are needed to color a given graph? Graph colorings

  6. A clique of size n is a graph with n vertices where all vertices have edges between them. Graph colorings

  7. Modern computers do operations (+, -, *, etc.) on registers. Fixed number of these (x86 architecture has 8, x64 has 16). When compiling code, need to assign variables to registers to use them. Register allocation

  8. Register allocation

  9. Register allocation

  10. In fact, this is always true for interval graphs – the number of registers needed (i.e. the number of colors to color the graph) is equal to the size of the largest clique! Register allocation

  11. Unfortunately, even finding the largest clique in a graph is NP-hard, but a greedy algorithm does pretty well. Register allocation

  12. Another problem: what if there aren't enough registers? Register allocation

  13. Work on questions 1-6 on the worksheet! Worksheet, part 1

  14. Mmmm.... Cookies!

  15. On a computer, all you have are bits (0's and 1's). How can you send a text message to another computer? Sending a message

  16. ASCII is a standard way to turn characters into bits. A = 65 = 01000001 B = 66 = 01000010 ... Z = 90 = 01011010 ASCII encoding

  17. What if we just want to send letter and a little punctuation? We can use a smaller code: a = 0 = 00000 b = 1 = 00001 ... <space> = 26 = 11010 5 bits means 2^5 = 32 characters Modified ASCII

  18. Our modified ASCII uses 5 bits per character. Sample message: “hello mom, how are you?” is 22 characters * 5 bits/character = 110 bits. How could we reduce the average number of bits per character? Modified ASCII

  19. Not all letters are created equal. “e” is much more common than “x” in most English text. We could take advantage of this if we made the code for “e” smaller than the code for “x”. Shrinking the message

  20. “o” and “ ” are the most commonly used letters in our sample message. Let “o” = 0 “ “ = 1 “m” = 00 .... Will this work? Shrinking the message

  21. A prefix-free code is one in which no code word is a prefix of another. “o” = 0 “ “ = 1 “m” = 00 is not prefix free, since “o”=0 is a prefix of “m”=00. Prefix-free code

  22. A binary tree is a common data structure where each node has up to two children. Binary tree

  23. What if we assign a character to each leaf? Binary tree

  24. We want a way to build up a binary tree where the least common characters are lower. (i.e. their code words are longer) We can do this by starting at the bottom and always combining the least common two characters, and continuing until we've formed a binary tree. Huffman encoding

  25. Example: “hello mom, how are you?” Huffman encoding

  26. Using Huffman encoding lets us send the message in 78 bits, as opposed to 110. With longer message, you can get even greater savings. Huffman encoding

  27. Work on questions 7-12 on the worksheet! Worksheet, part 2

More Related