python - Timsort stack invariant - Why do you want to delay the merging as long as possible? -
i trying understand timsort algorithm, have trouble following reason of implementing stack invariant:
- a > b+c
- b > c
according this document,
we delay merging long possible in order exploit patterns may come later, more merging possible exploit run found still high in memory hierarchy.
i understand want merging possible in order exploit cache effect, don't understand reason why want delay it. "patterns" mean that?
patterns here referring patterns in data being sorted. example, timsort looking increasing (or decreasing) runs in data, either sorted, of can sorted trivially reversing run in-place. tries use these runs mergesort partitions.
by way, wikipedia article on timsort may useful you: https://en.wikipedia.org/wiki/timsort
Comments
Post a Comment