jaspervdj / jaspervdj

Source code of my personal home page.

Home Page:jaspervdj.be

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug in "Better" Lazy Sort algorithm

HuwCampbell opened this issue · comments

I'm not sure if you're interested in this one, but you mentioned the higher complexity of the smallestN_smart and whether it's really worth it.

The implementation also has a bug in that the wrong number of items can be returned if the map builds up "small" numbers first.

image

The issue is that the comparison on the first guard with the size of the map, should be the sum of the elements of the map.

@HuwCampbell Thanks for letting me know! I've now fixed this in the blogpost in 17ef159. I also regenerated the graphs but it didn't seem to make a significant difference.