Tradeoffs between branch mispredictions and comparisons for sorting algorithms

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

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

  • Venue:
  • WADS'05 Proceedings of the 9th international conference on Algorithms and Data Structures
  • Year:
  • 2005

Quantified Score

Hi-index 0.00

Visualization

Abstract

Branch mispredictions is an important factor affecting the running time in practice. In this paper we consider tradeoffs between the number of branch mispredictions and the number of comparisons for sorting algorithms in the comparison model. We prove that a sorting algorithm using O(dn log n) comparisons performs Ω(n logdn) branch mispredictions. We show that Multiway MergeSort achieves this tradeoff by adopting a multiway merger with a low number of branch mispredictions. For adaptive sorting algorithms we similarly obtain that an algorithm performing O(dn(1 + log(1 + Inv/n))) comparisons must perform Ω(n logd(1 + Inv/n)) branch mispredictions, where Inv is the number of inversions in the input. This tradeoff can be achieved by GenericSort by Estivill-Castro and Wood by adopting a multiway division protocol and a multiway merging algorithm with a low number of branch mispredictions.