Skip to content

Comment on Binary array setparent

Comments

I was curious enough to have a go at implementing the same algorithm using a single vector [0], but it still runs about twice as slow as the original.

std::set is almost 4x faster on my machine.

A straight binary sorted vector is even faster. But degrades when the input is highly "unsorted" because of vector manipulations.

[0] doesn't show any sensitivity to insert order, which is a bit odd.

https://gist.github.com/codr7/d94ef02a5949cb01c57038c606838d...

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.