Skewed Binary Search Trees

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%.

[1]  Alok Aggarwal,et al.  The input/output complexity of sorting and related problems , 1988, CACM.

[2]  Alon Itai,et al.  How to Pack Trees , 1999, J. Algorithms.

[3]  Rudolf Bayer,et al.  Organization and maintenance of large ordered indexes , 1972, Acta Informatica.

[4]  Gerth Stølting Brodal,et al.  Cache-Oblivious Algorithms and Data Structures , 2004, SWAT.

[5]  Sartaj Sahni,et al.  Handbook of Data Structures and Applications , 2004 .

[6]  Jeffrey Scott Vitter,et al.  External memory algorithms and data structures: dealing with massive data , 2001, CSUR.

[7]  Panos M. Pardalos,et al.  Handbook of Massive Data Sets , 2002, Massive Computing.

[8]  Niklaus Wirth,et al.  Algorithms and Data Structures , 1989, Lecture Notes in Computer Science.

[9]  Erik D. Demaine,et al.  Worst-Case Optimal Tree Layout in a Memory Hierarchy , 2004, ArXiv.

[10]  Susanne Albers,et al.  Algorithms – ESA 2004 , 2004, Lecture Notes in Computer Science.

[11]  Matteo Frigo,et al.  Cache-oblivious algorithms , 1999, 40th Annual Symposium on Foundations of Computer Science (Cat. No.99CB37039).

[12]  Sebastian Winkel,et al.  Super Scalar Sample Sort , 2004, ESA.

[13]  Jing Wu,et al.  A locality-preserving cache-oblivious dynamic dictionary , 2002, SODA '02.

[14]  Gerth Stølting Brodal,et al.  On the adaptiveness of Quicksort , 2004, JEAL.

[15]  Lars Arge,et al.  Cache-Oblivious Data Structures , 2004 .

[16]  Michael A. Bender,et al.  Cache-oblivious B-trees , 2000, Proceedings 41st Annual Symposium on Foundations of Computer Science.

[17]  Torben Hagerup,et al.  Algorithm Theory - SWAT 2004 , 2004, Lecture Notes in Computer Science.

[18]  Gerth Stølting Brodal,et al.  Cache oblivious search trees via binary trees of small height , 2001, SODA '02.

[19]  Lars Arge External memory data structures , 2002 .

[20]  Gerth Stølting Brodal,et al.  Tradeoffs Between Branch Mispredictions and Comparisons for Sorting Algorithms , 2005, WADS.

[21]  Edward M. Reingold,et al.  Binary search trees of bounded balance , 1972, SIAM J. Comput..

[22]  Michael A. Bender,et al.  Efficient Tree Layout in a Multilevel Memory Hierarchy , 2002, ESA.