Hacker News new | ask | show | jobs
by namanbharadwaj 4623 days ago
By lazy, thesz is referring to a property of the data structure, not lazy evaluation.

`sort xs` evaluates to a data structure which contains the original unsorted sequence.

When asked for the ith element, the datastructure uses quickselect to produce the ith smallest element, while also partially sorting the sequence.

Repeated requests for the ith element will become faster and faster, as the sequence becomes more and more sorted.

1 comments

Repeated requests for the i-th element will not become 'faster and faster' but instead would simply be Θ(i) - they'd traverse i list pairs, then read the memoized data component.