Skewed binary search trees

  • Authors:
  • Gerth Stølting Brodal;Gabriel Moruz

  • Affiliations:
  • BRICS, Department of Computer Science, University of Aarhus, Århus, Denmark;BRICS, Department of Computer Science, University of Aarhus, Århus, Denmark

  • Venue:
  • ESA'06 Proceedings of the 14th conference on Annual European Symposium - Volume 14
  • Year:
  • 2006

Quantified Score

Hi-index 0.00

Visualization

Abstract

It is well-known that to minimize the number of comparisons a binary search tree should be perfectly balanced. Previous work has shown that a dominating factor over the running time for a search is the number of cache faults performed, and that an appropriate memory layout of a binary search tree can reduce the number of cache faults by several hundred percent. Motivated by the fact that during a search branching to the left or right at a node does not necessarily have the same cost, e.g. because of branch prediction schemes, we in this paper study the class of skewed binary search trees. For all nodes in a skewed binary search tree the ratio between the size of the left subtree and the size of the tree is a fixed constant (a ratio of 1/2 gives perfect balanced trees). In this paper we present an experimental study of various memory layouts of static skewed binary search trees, where each element in the tree is accessed with a uniform probability. Our results show that for many of the memory layouts we consider skewed binary search trees can perform better than perfect balanced search trees. The improvements in the running time are on the order of 15%.