C++ implementations of these two algos, with a way to create graphs and see when they explode