59 24 35 78 61 42 90 88 15 57
66 22 81 23 50 73 39 33 42
NOTE: For this problem, you should show the max-heap after each individual element is inserted so you don't get lost.
f = float("inf") vertices = ["New York", "Pittsburgh", "Los Angeles", "Dallas", "Atlanta"] edges = [ [f, 5, 2, 6, 1], [5, f, 8, f, 3], [2, 8, f, 7, 4], [6, f, 7, f, 9], [1, 3, 4, 9, f] ]
Once you decode the word, you can use python3 to check your answer. First, put the functions make_pq and build_tree into a file huffman.py. Then:
python3 -i huffman.py >>> from PythonLabs.BitLab import PriorityQueue, Node, assign_codes, encode, decode >>> table = [ ["'", 0.068], ["A", 0.262], ["E", 0.072], ["H", 0.045], ["I", 0.084], ["K", 0.106], ["L", 0.044], ["M", 0.032], ["N", 0.083], ["O", 0.106], ["P", 0.030], ["U", 0.059], ["W", 0.009] ] >>> pq = make_pq(table) >>> tree = build_tree(pq) >>> ht = assign_codes(tree) >>> encode(INSERT_YOUR_ANSWER_HERE_AS_A_STRING, tree) 0001011000111110000100110
A 0000 U 0100 L 1000 W 1100 E 0001 ' 0101 M 1001 I 0010 H 0110 N 1010 O 0011 K 0111 P 1011
Go to Popular Hawaiian Words and Phrases. Find a word that would be longer if encoded with the Huffman tree than with the 4-bit fixed-width code above. Give the encoding using the Huffman tree and the 4-bit fixed-width code above to justify your answer.
The check digit is computed using the following algorithm:
1. Add the first, third, fifth, seventh, ninth and eleventh digits of the UPC barcode and store this result in x. 2. Add the second, fourth, sixth, eighth and tenth digits of the UPC barcode and store this result in y. 3. Set z equal to the last digit of the value 3x + y. 4. If z is not equal to 0, then set check_digit equal to 10 - z. Otherwise, set check_digit equal to z.
32390001453_
718123006804
Is there an error in the barcode? Show your computation to justify your answer.
Decode the encoded image by filling in the appropriate pixels and state what the image represents.