Skip to content

This repository contains the implementation of the HaNoi Tower problem using the stack data structure in the context of learning about data structures and algorithms.

Notifications You must be signed in to change notification settings

ToanNguyenKhanh/HaNoi-Tower-project-using-Stack

Repository files navigation

This project implements the classic Tower of Hanoi problem using a stack data structure in C#. The Tower of Hanoi is a mathematical puzzle that involves three rods and a number of disks of different sizes which can slide onto any rod. The puzzle starts with the disks in a neat stack in ascending order of size on one rod, the smallest at the top, thus making a conical shape.

Demo video

Result

The objective of the puzzle is to move the entire stack to another rod, obeying the following simple rules:

Only one disk can be moved at a time.
Each move consists of taking the top disk from one stack and placing it on top of another stack i.e., a disk can only be moved if it is the uppermost disk on a stack.
No disk may be placed on top of a smaller disk.

Files Included:

Program.cs: This file contains the main implementation of the Tower of Hanoi problem using a stack data structure. It includes the necessary functions to solve the problem recursively.

Stack.cs: This file contains the definition of the Stack class, which is used to implement the stack data structure.

README.md: This readme file provides information about the project, its purpose, and how to use it.

How to Use:

Clone or download the repository to your local machine.

Open the project in your favorite C# development environment, such as Visual Studio or Visual Studio Code.

Build and run the project.

Follow the on-screen instructions to input the number of disks and see the steps to solve the Tower of Hanoi problem.

Contributing:

Contributions to this project are welcome. If you find any issues or have suggestions for improvement, feel free to open an issue or create a pull request.

License:

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments:

This project was inspired by the classic Tower of Hanoi problem and the concept of using stacks to solve it. Special thanks to the developers and contributors of the C# language and .NET framework for providing the foundation for implementing the stack data structure in C#.

About

This repository contains the implementation of the HaNoi Tower problem using the stack data structure in the context of learning about data structures and algorithms.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages