Average- and worst-case complexity