C++
--
Questions
--
Followers
Top Experts
Towers of Honoi need iterative code solution in C++
I'm writing a paper on the recursive and iterative approach to solve Towers of Hanoi problem. Recursive approach is all over the internet. The iterative approach is not. I need C++ code that will solve the towers of Honoi problem with 3 pegs and up to 25-30 disks. In order to get points you must answer question with code, the code most run in C++ 6.0 compiler with brief comments so I can analyze whats going on. I give no partial points for kind of being right or pointing to some link that sort of talks about it. Your code will not be used in my paper but the timed results (i supply code for timing) for varoius amount of disks will, FYI.
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
ASKER CERTIFIED SOLUTION
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
It's not an explicit c++ solution, but the switch should be easy.
It's been a REALLY long time since I calculated the time to move disks, but I seem to remember that when you start to get above 20, the time gets impossibly long. I remember the algorithm relating to prime numbers, etc. So, just a warning in case you decide to run this for large amounts of disks, it could days or more.
Then again, this was back when the fastest desktop computer was a 60 MHz PowerPC...
Let us know your results in this thread if possible.
Then again, this was back when the fastest desktop computer was a 60 MHz PowerPC...
Let us know your results in this thread if possible.
One question though solving the towers from an iterative prospective how exactly is it done. What was the old way of solving the problem and is the code still out there some where. I would like to compare the old way with his new more efficient code. Yes I will post my results using a system that has 2100XP.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
C++
--
Questions
--
Followers
Top Experts
C++ is an intermediate-level general-purpose programming language, not to be confused with C or C#. It was developed as a set of extensions to the C programming language to improve type-safety and add support for automatic resource management, object-orientation, generic programming, and exception handling, among other features.