Midterm II (EX2) Review Questions

CS 4521, Fall 2000

Ch. 13 - Binary Search Trees

  1. In a traversal of a binary tree, you visit each node three times: once preorder, once inorder, and once postorder. When do these visits occur in relation to traversing the left and right subtrees?
  2. What are average and worst-case runtimes for adds and removes in an unbalanced binary tree implementation of a Table?

Ch. 14 - Red-Black Trees

  1. What are the two most important conditions on red-black trees?
  2. What are average and worst-case runtimes for adds and removes in an red-black tree implementation of a Table?
  3. When you first add a node in a red-black tree, what color is the new node? What problem can this cause?
  4. You are adding an entry to a red-black tree. You are at a node whose children are both red, and the right child of the left child is also red. What steps do you take? What information do you pass to the next level up?
  5. You are adding an entry to a red-black tree. You are at a node whose left child is red, and whose right child is black. The right child of the left child is red. What steps do you take? What will you need to do at the next level up?
  6. You are adding an entry to a red-black tree. You are at a node whose left child was just made red. What steps do you take? Will you need to do anything at the next level up?
  7. You have just removed a red node from a red-black tree. What do you need to do to rebalance the tree?
  8. You are removing an entry from a red-black tree. All paths through the left child of the current node are short by one black node. The right child is red. What steps do you take? Will you need to do anything at the next level up?
  9. You are removing an entry from a red-black tree. All paths through the left child of the current node are short by one black node. The right child is black and the right child of the right child is red. What steps do you take? Will you need to do anything at the next level up?
  10. You are removing an entry from a red-black tree. All paths through the left child of the current node are short by one black node. The right child is black and both of its children are black. What steps do you take? Will you need to do anything at the next level up?
  11. After an add in a red-black tree, what is the maximum number of rotations required to rebalance the tree?
  12. After a remove in a red-black tree, what is the maximum number of rotations required to rebalance the tree?
  13. How does red-black tree balancing affect the average runtimes for table operations?

Ch. 2, 18 - Growth of Functions, Amortized Analysis

  1. Describe what is meant by the following:
    1. T(n) = O(f(n))
    2. T(n) = Theta(f(n))
    3. T(n) = Omega(f(n))

  2. What is the difference between average and amortized runtimes?

Ch. 20 - Binomial Heaps

  1. How many entries does a binomial tree of rank n have?
  2. What conditions does a binomial tree satisfy?
  3. How do you join two binomial trees? When is this a legitimate operation for binomial trees?
  4. How do you do an add to a binomial heap?
  5. How do you do a remove from a binomial heap?
  6. A binomial heap has four binomial trees. Their degrees are 0, 1, 2, and 4. After you add an entry, how many binomial trees will the heap have? What are the degrees of the trees?

Ch. 21 - Fibonacci Heaps

  1. What is the primary difference between binomial heaps and Fibonacci heaps?