Documente Academic
Documente Profesional
Documente Cultură
NAME: ___________________________SOLUTIONS_____________________________________
RUID:___________________________________________________________________________
Electronic Devices are not permitted during the quiz. These include but are not restricted to calculators, computers and cell phones. No communication between students or anyone outside of class is permitted during the quiz. Textbooks, notes and any other written materials are not permitted during the quiz.
1. For each of the following trees, write True if it is a binary search tree where items are maintained in alphabetical order. Otherwise, write False. B cannot appear left of A because B>A ____False____ a) Several other problems exist
____False____ b)
____True____ c)
____True____ d)
2. For each of the following codes, write True if it is a prefix code. Otherwise, write False.
____True________ a)
____False_______ b)
a: 0, e: 1, t: 01, s: 001
t starts with as bit string. Thus, ambiguity will arise within any transmitted messages
____True________ c)
____True________ d)
3. For each of the following codes, compute the average number of bits to encode a single character if the character frequencies are as shown. Additionally, specify whether or not the code is a Huffman code (write True if it is a Huffman Coding, otherwise write False). a) code: frequencies: a: 10, b: 11
a: 0.1,
b: 0.9
Average bits = 0.1 * 2 + 0.9 * 2 = 2 Not a Huffman code because too many bits are used. a Huffman code. [a:0 b:1] would be
b)
code: frequencies:
a:
10,
b:
11,
c:
a: 0.2,
b: 0.3,
c: 0.5
c)
code: frequencies:
a: 110000, a: 0.1,
b:
01,
c: 001 c: 0.4
b: 0.5,
Average bits = 0.1 * 6 + 0.5 * 2 + 0.4 * 3 = 2.8 Not a Huffman code because too many bits are used. would be a Huffman code. [a:00 b:1 c:01]
For each of the blanks below, select the correct visitation order of vertices for the specified type of traversal. A) a, b, c, d, e, f, g, h C) h, g, f, e, d, c, b, a E) a, b, c, d, e, f, g, h G) h, g, f, e, d, c, b, a I) c, b, d, a, f, g, h, e K) h, g, e, f, a, d, b, c M) c, d, b, f, g, h, e, a O) h, g, f, e, d, c, b, a B) a, b, e, c, d, f, g, h D) a, e, b, f, d, c, h, g F) h, g, f, d, c, e, b, a H) g, h, c, d, f, b, e, a J) c, d, g, h, b, f, a, e L) c, d, b, g, h, f, e, a N) c, b, d, a, e, g, f, h P) h, f, g, e, a, d, b, c
Q) That type of traversal is impossible for this tree R) None of the above answers is correct
5. Compute the value of each of the following expressions assuming each is in prefix, infix or postfix notation as indicated. (As in the book, indicates exponentiation.) If the value cannot be computed due to lack of operators or lack of operands, write Impossible.
_____40______ f) Postfix: 9 3 / 5 + 7 2 - * (9 3 /) 5 + 7 2 - * = (3 5 +) 7 2 - * = 8 (7 2 -) * = (8 5 *) = 40