CS 223
Final Exam
Ondich
Due on paper 5:00 PM Monday, June 4, 2001

This is an open-book, open-notes, open-computer, open-brain (your own only, please), and open-Internet exam. It is an exam, however, so limit your discussion of the exam to conversations with Jeff Ondich.

Explain your answers clearly.

This exam has been formatted in HTML, which is not especially good at displaying mathematical notation. Where appropriate, I have used C++ style notation (e.g. <= for less than or equal to, and &&, ||, and ! for logical And, Or, and Not, respectively). If you have questions about any of the notaion on this exam, please let me know.

  1. A Little Logic (10 points)

  2. Inversions (12 points) Consider the sample space S4 consisting of all the permutations of the integers 1, 2, 3, and 4 (that is, you're going to imagine an experiment where you randomly pick a permutation, where all permutations are equally likely).

    An inversion in a permutation is a pair of integers where the left integer is larger than the right integer. For example, (1,3,4,2) has two inversions, because 3 is left of 2, and 4 is left of 2.

    Let A = {p in S4 | p has exactly 3 inversions}, let B = {p in S4 | the rightmost integer in p is 1}, and let X be the random variable on S4 defined by X(p) = the number of inversions in p.

  3. Height-balanced binary trees (12 points)

    A height-balanced binary tree (HBBT) is a binary tree, each of whose nodes has the following property: the height of the left subtree and the height of the right subtree differ by at most 1. (You have encountered this idea before if you have studied AVL trees, which are height-balanced binary search trees.)

    In this problem, you are going to work through a proof that the height of a HBBT is O( log N ), where N is the number of nodes in the tree. (We'll stop there, but your proof could be used to show that AVL trees have guaranteed insertion, deletion, and search times that are O( log N ).)

  4. Obligatory Foolishness (3 points) Please tell me a joke.

  5. Gray Codes (12 points) Take the set of all 3-bit binary numbers {000, 001, ..., 111} and consider each to be a node of a graph G. Furthermore, suppose any pair of nodes in G will have a connecting edge if and only if the two numbers differ in exactly one bit (so 101 and 100 are connected, but 110 and 101 are not).

  6. Have a great summer.