1.
In
1952, Huffmann (while a graduate student) devised an algorithm that
could be
used to construct a variable-length set of codes to represent the
characters
(or words) that make up a given text. This
algorithm is an example of a greedy
algorithm
(i.e., an
algorithm that determines a globally optimal solution by making locally
optimal
choices). The encoding schemes generated are immediately
decodable, and each character is guaranteed to have a minimal expected
code length.
Given
the following characters and
their weights:
~ = .02
@ = .18
# =
.10
$ =
.12
% = .10
& = .28
* = .20
Generate
a Huffman tree for the
above characters with respect to the given weights.
Use
the tree to derive the code
assigned to each character. Compute the
expected code length.
Is
the tree generated the only one
that can be generated for this problem set?
________________________
Are
the codes generated the only
ones that can be generated for this problem set? ____________________
1.
AVL
trees are binary search trees in which the balance factor or each node
is 0, 1,
or -1. When insertions to an AVL tree
cause it to become unbalanced, the tree is rebalanced through one or
more
rotation operations.
Show
the construction of the AVL
tree that results from inserting the following numbers in the order
given. Show the tree and balance factors
for each
node before and after each rebalancing: 100, 200, 700, 12, 500, 17, 350, 16, 54, 400, 600, 800.
2.
Unlike
AVL trees, which must be rebalanced after almost half of the insertions
(and
are binary trees),