Hanoi Puzzle, Complexity Analysis of the Recursive, Iterative, and RBC Approaches
This paper focuses mainly on the time and space complexity computation of the Tower of Hanoi, this mathematical game or puzzle is a well-known problem for its exponential time consumption, which is challenging in terms of performance, especially with the rising of its implications in education purpo...
Saved in:
| Published in | Integrated STEM Education Conference (Online) pp. 1 - 4 |
|---|---|
| Main Authors | , |
| Format | Conference Proceeding |
| Language | English |
| Published |
IEEE
15.03.2025
|
| Subjects | |
| Online Access | Get full text |
| ISSN | 2473-7623 |
| DOI | 10.1109/ISEC64801.2025.11147343 |
Cover
| Summary: | This paper focuses mainly on the time and space complexity computation of the Tower of Hanoi, this mathematical game or puzzle is a well-known problem for its exponential time consumption, which is challenging in terms of performance, especially with the rising of its implications in education purposes, in addition to its exploration in machine learning algorithms for artificial intelligence ingenuities. The present work contrasts the exploited hardware resource. Hence, the running time and the space consumption of both the recursive and the iterative algorithms will be compared with the proposed gray code-based solution. Using the very popular programming language Python, the results of the performed measurements show a very high consumption of the gray code-based algorithm compared to the recursive and the iterative ones, either in terms of time or space complexity. Furthermore, the bytecode of these algorithms in terms of instructions is much lighter than the reflected binary code technique. Finally, regarding these results, the authors highly recommend using the iterative approach in machine learning when handling large data sets, while the elegant recursive algorithm is still fine when dealing with small or moderate data volumes, whereas the gray code-based algorithm must be considered mostly for educational uses or for scientific purposes. |
|---|---|
| ISSN: | 2473-7623 |
| DOI: | 10.1109/ISEC64801.2025.11147343 |