Work Note 11, DM803, fall 2016

Exercises November 24

  1. Reconsider the operations meld and split from the last exercises, but now in a context where the red-black trees are leaf-oriented, i.e., the real keys are all in the leaves, and the internal nodes just contain routers (that could be copies of existing or old keys), directing a search in the right direction.
  2. We have argued in class that a single rotation preserves the search tree invariant. Argue more broadly that this is also the case for the following: Consider any connected subgraph of nodes in a search tree (for the single rotation, the subgraph has two nodes). Now, remove all trees hanging off nodes in this subgraph in an in-order fashion and, separately, all the keys of nodes of the subgraph in an in-order fashion. Then rearrange the subgraph into any other connected subgraph. Add the keys to the nodes in-order and attach the trees again, also inorder. Argue that the tree is a search tree.
  3. For Y-Fast Tries, we had to keep the sizes of the small red-black trees in the range [(log M) / 4, 2 log M]. Thus, for deletion, when a tree got too small, we would merge it with a neighbor. If this merge was then above or too close to the high end of the allowed interval, we would split into two even-sized trees (±1). Choose when to split with the aim of maximizing the worst-case distance to one of the extreme points of the allowed interval for any of the up to two trees involved that will be created. (In the lecture, we arbitrarily chose to split if the size exceeded (3/2) log M.)
  4. Show that the splay operations can be formulated as at most two single rotations.
  5. Compute the potential of a perfectly balanced tree as well as the potential of a tree which has deteriorated to a linked list.
  6. At the lecture, we did the amortized analysis of only one of the splay operations; the one where x was the left child of a left child. Complete the analysis of the other operations as well.
  7. This is an open exercise problem; not necessarily in the sense that it is unknown in general, but I do not have the answer: How unbalanced can you make a splay tree? You could answer this for small n; possible by writing a program and performing some sort of exhaustive search. Can one arrange imbalance for families of access sequences for growing n? Note that this is starting with an empty tree and applying insertions and accesses, and that a newly inserted node is also splayed to the top. Using deletion is cheating... :)
  8. Assume writes cost c times more than reads (this is the case on a USB key, for instance). Go through the standard sorting algorithms and determine the asymptotic complexity as a function of both n and c, i.e., you have to calculate number of reads and writes separately. Do any of them have O(cn) writes? Do any of them run in O(n log n + cn)? Can you obtain the latter somehow?

Lecture November 28


Last modified: Mon Nov 21 14:04:14 CET 2016
Kim Skak Larsen (kslarsen@imada.sdu.dk)