You are on page 1of 7

CS 205 Quiz #8B Nov 20, 2012

NAME: __________________________________________________________________________

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.

DO NOT OPEN UNTIL


INSTRUCTED TO DO SO

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.

_____________ a)

_____________ b)

_____________ c)

_____________ d)

2. For each of the following codes, write True if it is a prefix code. Otherwise, write False.

________________ a)

a: 00, e: 01, t: 10, s: 11

________________ b)

a: 0, e: 10, t: 110, s: 1110

________________ c)

a: 1, e: 10, t: 100, s: 1000, n: 10000

________________ d)

a: 00, e: 01, t: 1000, s: 101, n: 110, i: 111

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:

0,

a: 0.6,

b:

b: 0.4

Average Bits: ____________________

b)

code:

a: 100,

b: 101,

c: 110,

d: 111

frequencies:

a: 0.2,

b: 0.3,

c: 0.2,

d: 0.3

Average Bits: ____________________

c)

Huffman Code: ________________

code:
frequencies:

Huffman Code: ________________

a: 00110,

b:

10,

c: 110

a:

b: 0.4,

c: 0.5

0.1,

Average Bits: ____________________

Huffman Code: ________________

4. Consider the following tree rooted at node a.

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, i, j, k, l

B) l, k, j, i, h, g, f, e, d, c, b, a

C) f, b, j, d, a, g, k, c, h, e, l, i

D) l, i, e, k, h, c, g, j, d, a, f, b

E) a, b, c, d, f, g, j, k, e, h, i, l

F) l, i, e, h, c, d, g, k, j, f, a, b

G) b, a, f, d, j, g, k, c, h, e, l, i

H) i, l, e, h, c, k, g, j, d, f, a, b

I) b, f, j, k, g, d, h, l, i, e, c, a

J) a, c, e, i, b, d, h, l, g, k, f, j

K) a, c, e, i, l, h, d, g, k, j, f, b

L) j, k, l, f, g, h, i, d, e, b, c, a

M) l, i, h, e, k, j, g, f, d, c, b, a

N) a, c, b, e, d, i, h, g, f, l, k, j

O) b, a, c, d, e, f, g, j, k, h, l, i

P) i, e, c, a, l, h, d, b, k, g, j, f

Q) That type of traversal is impossible for this tree


R) None of the above answers is correct

_____________ i) Preorder Traversal

_____________ ii) Inorder Traversal

_____________ iii) Postorder Traversal

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.

_____________ a) Prefix: + - 3 2 2 3 / 6 4 2

_____________ b) Prefix: * + 3 + 3 3 + 3 3 3

_____________ c) Infix: (5 + 4) (((3 1)/2) * 1)

_____________ d) Infix: (9 + ((7 * (5 2)) / 5)) * 0

_____________ e) Postfix: 5 2 1 - - 3 1 4 + + *

_____________ f) Postfix: 3 2 * 2 5 3 8 4 / * -

Scratch Paper

You might also like