# Depth of a Random Binary Search Tree with Concurrent Insertions

## Abstract

Shuffle a deck of *n* cards numbered 1 through *n*. Deal out the first *c* cards into a hand. A player then repeatedly chooses one of the cards from the hand, inserts it into a binary search tree, and then adds the next card from deck to the hand (if the deck is empty). When the player finally runs out of cards, how deep can the search tree be?

This problem is motivated by concurrent insertions by *c* processes of random keys into a binary search tree, where the order of insertions is controlled by an adversary that can delay individual processes. We show that an adversary that uses any strategy based on comparing keys cannot obtain an expected average depth greater than \(O(c + \log n)\). However, the adversary can obtain an expected tree height of \(\varOmega (c \log (n/c))\), using a simple strategy of always playing the largest available card.

## Notes

### Acknowledgements

Funding for the second author was provided by the Natural Sciences and Engineering Research Council of Canada.

## References

- 1.Booth, A.D., Colin, A.J.T.: On the efficiency of a new method of dictionary construction. Inf. Control
**3**(4), 327–334 (1960)MathSciNetCrossRefzbMATHGoogle Scholar - 2.Bronson, N.G., Casper, J., Chafi, H., Olukotun, K.: A practical concurrent binary search tree. In: Proceedings of the 15th ACM Symposium on Principles and Practice of Parallel Programming, pp. 257–268 (2010)Google Scholar
- 3.Brown, T., Ellen, F., Ruppert, E.: A general technique for non-blocking trees. In: Proceedings of the 19th ACM Symposium on Principles and Practice of Parallel Programming, pp. 329–342 (2014)Google Scholar
- 4.Culberson, J., Munro, J.I.: Explaining the behaviour of binary search trees under prolonged updates: a model and simulations. Comput. J.
**32**(1), 68–75 (1989)MathSciNetCrossRefGoogle Scholar - 5.Devroye, L.: A note on the height of binary search trees. J. ACM
**33**(3), 489–498 (1986)MathSciNetCrossRefzbMATHGoogle Scholar - 6.Drmota, M.: An analytic approach to the height of binary search trees II. J. ACM
**50**(3), 333–374 (2003)MathSciNetCrossRefzbMATHGoogle Scholar - 7.Ellen, F., Fatourou, P., Ruppert, E., van Breugel, F.: Non-blocking binary search trees. In: Proceedings of the 29th ACM Symposium on Principles of Distributed Computing, pp. 131–140 (2010)Google Scholar
- 8.Guibas, L.J., Sedgewick, R.: A dichromatic framework for balanced trees. In: Proceedings of the 19th IEEE Symposium on Foundations of Computer Science, pp. 8–21 (1978)Google Scholar
- 9.Mahmoud, H.M.: Evolution of Random Search Trees. Wiley, New York (1992)Google Scholar
- 10.Manthey, B., Reischuk, R.: Smoothed analysis of binary search trees. Theoret. Comput. Sci.
**378**(3), 292–315 (2007)MathSciNetCrossRefzbMATHGoogle Scholar - 11.Mitzenmacher, M., Upfal, E.: Probability and Computing: Randomized Algorithms and Probabilistic Analysis, Chap. 12. Cambridge University Press, Cambridge (2005)Google Scholar
- 12.Reed, B.: The height of a random binary search tree. J. ACM
**50**(3), 306–332 (2003)MathSciNetCrossRefzbMATHGoogle Scholar - 13.Robson, J.M.: The height of binary search trees. Aust. Comput. J.
**11**(4), 151–153 (1979)MathSciNetGoogle Scholar - 14.Williams, D.: Probability with Martingales. Cambridge University Press, Cambridge (1991)Google Scholar
- 15.Windley, P.F.: Trees, forests and rearranging. Comput. J.
**3**(2), 84–88 (1960)CrossRefzbMATHGoogle Scholar