Presentation is loading. Please wait.

Presentation is loading. Please wait.

Huffman Coding Draw the tree, label all nodes w/ index, leaves w/ letter and all links(0 or 1) What is the most frequent letter? What is the least frequent.

Similar presentations


Presentation on theme: "Huffman Coding Draw the tree, label all nodes w/ index, leaves w/ letter and all links(0 or 1) What is the most frequent letter? What is the least frequent."— Presentation transcript:

1 Huffman Coding Draw the tree, label all nodes w/ index, leaves w/ letter and all links(0 or 1) What is the most frequent letter? What is the least frequent letter?

2 3 14 5 2 0 6 78 0 0 0 0 1 1 1 1 R B F O A Encode FOOBAR:______________________________________________________ Write down the message coded by this sequence: 01101100011000 ___________________________________________________

3 Huffman Coding Draw the tree, label all nodes w/ index, leaves w/ letter and all links(0 or 1) 012345678 0001000001 1000101000 2000000000 3000000000 4110000000 5000000000 6000000000 7000000000 8000000110 What is the most frequent letter? What is the least frequent letter?

4 3 14 5 2 0 6 78 0 0 0 0 1 1 1 1 R L T E A Encode LATER:______________________________________________________ Is this a valid sequence: 010101101100111001111 ? Is this a valid sequence: 0011100100011101110 ?

5 Ternary Tries Insert these words into an initially empty ternary trie: Map Atom Stem Hash Treap AVL Hashing Trie

6 B-Trees Quick Review: *data records are stored only in the leaves *All the leaves are at the same level *Internal nodes store key values which guide searching in the tree *An internal node holds one fewer keys than it has children: the leftmost child has no key stored for it every other child has a key stored which is equal to the smallest key in the subtree rooted at that child

7 B-Trees: What does 2-3 mean? A B-tree with M=L=3 is called a 2-3 tree B-Trees are parameterized on M, L A leaf always holds between ceil(L/2.) and L data records (inclusive) An internal node always has between ceil(M/2.) and M children (inclusive) So, in a 2-3 tree, internal nodes have 2 or 3 children (But max 2 keys!) and leaves hold 2 or 3 records

8 Insert the following elements into a 2-3 B-Tree: 12, 5, 15, 25, 100, 125, 110, 115

9 Graphs – Unweighted Draw the graph What are both (2) BFS starting from index 0 visiting all vertices? What are all (3) DFS starting from index 0 visiting all vertices?

10 The transitive closure of a graph G is a graph that has the same vertices as G, and an edge from vertex i to vertex j if and only if there is a path from vertex i to vertex j in G. Show the adjacency list representation for the transitive closure of G:

11 Graphs – Weighted Draw the graph, then find the minimal spanning tree 01234 0081034 1805Inf2 210507Inf 33 701 442 10

12 Hashing – Chaining For Final: No Ordered Hashing or Brent’s Method Use Chaining to build a hashtable given, H(K) = K mod 5 And keys: 100, 50, 19, 48, 27, 12, 22

13 Hashing – Double vs. Chaining Primary hash function: H(K) = K mod 5 Secondary hash function: H2(K) = (K mod 4) + 1 Write down the order of insertion: If all keys are equally likely, what is the average # of probes for a successful search?

14 Given that the keys were inserted in this order: 27, 22, 25, 24, 21 Show the table using Chaining: If all keys are equally likely, what is the average # of probes for a successful search? Better than double hashing?

15 Disjoint Subsets The set of element labels is S={0,1,2,3,4,5,6}. The data structure after MAKESET(7) is shown in A. The data stucture after a sequence of UNION operations is shown in B. How many DS in B? Write down a sequence of calls to UNION that would transform A into B:

16 Given the system of disjoint subsets in B, write down the value of the following calls to FIND : FIND(0):__________ FIND(1):__________ FIND(2):__________ FIND(3):__________


Download ppt "Huffman Coding Draw the tree, label all nodes w/ index, leaves w/ letter and all links(0 or 1) What is the most frequent letter? What is the least frequent."

Similar presentations


Ads by Google