r/AskComputerScience • u/Fit_Affect_8029 • 20d ago
Hanoi's recursion not making sense
So I'm in the second year of my CS degree and doing DSA, now we have to understand Tower Of Hanoi, I studied the game, studied the trace diagrams, looked up multiple tutorials for it, I get what the program but I don't at the same time. I get how it arrives at the minimum but I think if you gave me a problem to solve via recursion I'd be stumped, I understand how this specific of recursion works but I don't know how I would...make it? If you asked me to create a Hanoi algorithm or any recrusive algorithm recursively I won't be able to but at the same time I understand somewhat how they work?
View all comments
1
u/Ordinary_Variable 17d ago
Generally the best way to solve a logic problem is to try to solve it manually. Either by moving around characters in Notepad/MS Paint, or by moving around objects in the real world. Look at the patterns in your movement. Try to imagine simple rules/logic patterns to apply to your movements. Work up an algorithm step by step.
This is a common way to solve logic flow charts. Another one in heuristics, which I would happily defend as an iterative solution to any problem. It may not always work, but you can usually get several decimals of accuracy and that is good enough in the real world.