The aim of coding for this particular solution is inspired by the SICP (Structure and Interpretation of Computer Programs) MIT video lectures by Prof. Abelson and Gerald Jay. The aim is to understand the recursive nature of the program.
The program is available at my bitbucket collection - click here (takes you to the page containing the code).
In order to understand the recursive nature of the program. you can compile it with debugging symbols -
gcc -g towers_of_hanoi.cpp
and then use the gdb debugger (learn it) to trace through the different stacks (a, b, c).
gdb a.out
Also, use backtrace (bt) command in gdb to trace through the system stack to get a better understanding of how the code implements the solution.
No comments:
Post a Comment