Added average-case analysis.