Re:Technical interviews and the Towers of Hanoi
by thaumaturgy on Monday January 05, 2015 @05:18PM
(#8841613)
Neat. Were you able to get his code to run? What did you change / what compiler flags did you use?
[ Parent
| on HN ]
Re:Technical interviews and the Towers of Hanoi
by pieguy on Monday January 05, 2015 @06:05PM
(#8841855)
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
Re:Technical interviews and the Towers of Hanoi
by thaumaturgy on Monday January 05, 2015 @06:13PM
(#8841891)
Thanks. 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!