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?
R B F O A Encode FOOBAR:______________________________________________________ Write down the message coded by this sequence: ___________________________________________________
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?
R L T E A Encode LATER:______________________________________________________ Is this a valid sequence: ? Is this a valid sequence: ?
Ternary Tries Insert these words into an initially empty ternary trie: Map Atom Stem Hash Treap AVL Hashing Trie
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
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
Insert the following elements into a 2-3 B-Tree: 12, 5, 15, 25, 100, 125, 110, 115
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?
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:
Graphs – Weighted Draw the graph, then find the minimal spanning tree Inf Inf
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
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?
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?
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:
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):__________