tangorishi / learnJava

LearnJava - Hacktoberfest 2023 🚀 Join us in celebrating Hacktoberfest 2023 by contributing to this Java programming repository! Whether you're a beginner or an expert, dive into Java, share your knowledge, and make Hacktoberfest unforgettable. 📚💻 Happy coding and contributing! 🚀🌟
MIT License
26 stars 45 forks source link

Create Tower of Hanoi.java #87

Closed competitiveblood closed 10 months ago

competitiveblood commented 10 months ago

fixed #86

Description

The above code is a Java implementation of the Tower of Hanoi algorithm using recursion. It works by moving the disks from one rod to another, using a third rod as a helper. The base case is when there is only one disk, which can be moved directly from the source rod to the destination rod. Otherwise, the algorithm moves the top n-1 disks from the source rod to the helper rod, then moves the largest disk from the source rod to the destination rod, and finally moves the top n-1 disks from the helper rod to the destination rod.

Testing Done

I tested the code with 4 disks and it worked correctly.

Additional Notes

The Tower of Hanoi algorithm is a classic example of a recursive algorithm. It is a good example of how to use recursion to solve a complex problem by breaking it down into smaller, simpler problems.

The code is well-written and easy to understand. It is also well-formatted and uses consistent coding style.

Overall, the code is a good implementation of the Tower of Hanoi algorithm.

tangorishi commented 10 months ago

use the pr template given in readme file

competitiveblood commented 10 months ago

Did the changes Kindly merge the PR.