Homework Assignment 6


Due: Mar. 16 before class starts


Assignment

  1. (30 points) Show that any n-node binary tree can be converted to any other n-node binary tree using O(n) rotations. Provide a statement and proof by construction.
  2. (40 points) Write and analyze an algorithm to find and construct a list of all elements within a range of keys (k1, k2) for a binary tree T. The algorithm must run in O(s+h) time, where s is the number of elements in the range and h is the height of the tree.
    1. Provide and explain pseudocode
    2. Statement and proof of time complexity
    3. Statement and proof of memory complexity
  3. (30 points) Lets assume your algorithm for the previous problem is modified to remove all elements within the range. State and prove the time complexity for this new algorithm for (1) a binary search tree and (2) and AVL tree.
  4. Bonus. (10 points) Show that the nodes of any AVL tree T can be colored "red" and "black" so that T becomes a red-black tree.


General Instructions, Turning in assignments, and Grading

General Instructions

Turn in Instructions

Each assignment will be turned in in class (hard copy). Assignments are due BEFORE, let me repeat, before class starts. This does not mean five minutes after class starts. Details:

Points