3 ms·
I removed the free() call because it was crashing. I also added a cast to the malloc() because I was compiling in C++. Compiled with g++ -o hanoi hanoi.cpp
by pieguy 12y ago
I removed the free() call because it was crashing. I also added a cast to the malloc() because I was compiling in C++. Compiled with
g++ -o hanoi hanoi.cpp -O2 -lrt
- thaumaturgy 12y agoThanks. I had also cast malloc() but didn't think to just comment out free(). So I'm seeing similar results as you. Your iterative implementation is about 3x faster than the author's, but still not as fast as the recursive version. I'm surprised!