Sorting Lower Bound
Sorting Lower Bound
no
Is xi < xj?
yes
© 2004 Goodrich, Tamassia Sorting Lower Bound 1 © 2004 Goodrich, Tamassia Sorting Lower Bound 2
xa < xb ? xc < xd ?
xa < xb ? xc < xd ?
log (n!)
xe < xf ? xk < xl ? xm < xo ? xp < xq ? xe < xf ? xk < xl ? xm < xo ? xp < xq ?
n!
© 2004 Goodrich, Tamassia Sorting Lower Bound 3 © 2004 Goodrich, Tamassia Sorting Lower Bound 4
The Lower Bound
Any comparison-based sorting algorithms takes at
least log (n!) time
Therefore, any such algorithm takes time at least
n
n 2
log (n!) ≥ log = (n / 2) log (n / 2).
2