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 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.

Authors

Institutions

Publication Details

Published
2025-03-15
DOI
https://doi.org/10.1109/isec64801.2025.11147343
Primary Topic
Computability, Logic, AI Algorithms
Type
article
Field-Weighted Citation Impact
0.00
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

Hanoi Puzzle, Complexity Analysis of the Recursive, Iterative, and RBC Approaches

Mohammad El Ghabzouri, Abdenacer Es Salhi
Computability, Logic, AI Algorithms
article

Hanoi Puzzle, Complexity Analysis of the Recursive, Iterative, and RBC Approaches

Mohammad El Ghabzouri, Abdenacer Es Salhi
article en

Abstract

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.

Mohammed V University (MA), Mohamed I University (MA)
Openalex Percentile: Top 75%
Computability, Logic, AI Algorithms
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.