Skip to content

O(N^2) if all elements are equal #7

@behdad

Description

@behdad

Hi,

I'm using this code in https://github.com/behdad/harfbuzz/, and our fuzzers have found a timeout for us, which I tracked down to this code performing slow. Upon inspection, it's clear that if all array elements are the same, the code performs at its worst case. The median-pivot method helps with the case of array being mostly sorted or reverse-sorted, but doesn't help all-the-same.

Given that elements equal to the pivot can be partitioned on either side, I'm going to modify the code to use that property to choose a more central breaking point. I'll report on my progress. Thanks.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions