-2

I am learning algorithms and came to this Hanoi Tower. I know how to do that practically. But I am unable to code it. I haven't read the given code yet. I am trying it first myself. What should be my approach-keep trying or read the given code or something else?

Should this approach be followed with all the algorithms?

Temp Id
  • 229
  • 1
  • 2
  • 6

2 Answers2

1

You may find this useful:

http://www.quora.com/Algorithms/How-does-one-become-good-at-solving-algorithm-programming-problems

A big takeaway from the post above:

Popular to contrary belief, I don't think coding solutions to algorithmic problems is a generally effective way to learn algorithms. The people who have done it successfully though are usually good/quick at spotting patterns and solving algorithmically oriented problems.

You need not actually write code to solve an example problem - just make sure you understand the underlying idea for solving it.

DanGar
  • 3,018
  • 17
  • 17
0

Watch this -

http://www.youtube.com/watch?v=uFJhEPrbycQ&list=SPFE6E58F856038C69

If you had 3 rings, how would you move the entire tower? Move the first top 2 rings to the temporary ring. Move the bottom ring to the destination. Then copy the 2 rings from the temp to the final.

The key to understand this is recursion and think about moving N-1 rings

runners3431
  • 1,425
  • 1
  • 13
  • 30