Open study

is now brainly

With Brainly you can:

  • Get homework help from millions of students and moderators
  • Learn how to solve problems with step-by-step explanations
  • Share your knowledge and earn points by helping other students
  • Learn anywhere, anytime with the Brainly app!

A community for students.

Hey kids, This lets you play test recursion at home without the Fisher Price Toys. He he! Have fun.

MIT 6.00 Intro Computer Science (OCW)
I got my questions answered at in under 10 minutes. Go to now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Join Brainly to access

this expert answer


To see the expert answer you'll need to create a free account at Brainly

IMHO, reversing a string, testing for a palindrome and converting base 10 numbers to other bases are more understandable programs to learn recursion than the Towers of Hanoi or the Towers of Brahma.
cool link, always looking for free resources
I agree that it's not the best example for recursion but is fun to play with. Something to try is this. def printMove(fr, to): global numCalls numCalls += 1 ## print('move from ' + str(fr) + ' to ' + str(to)) def Towers(n, fr, to, spare): if n == 1: printMove(fr, to) else: Towers(n-1, fr, spare, to) Towers(1, fr, to, spare) Towers(n-1, spare, to, fr) numCalls = 0 Towers(26, 'A', 'B', 'C') print numCalls notice I commented out the print in the printMove() function. This takes a little time to run but it gives you an idea of the complexity. Imagine how long it would take for 64 disks. Would I dare let it run that long? I don't know. Maybe some day. I would first want to put in some time start and time end markers.

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

For complexity I get 2^n-1. Is that about right?
For 64 disks then it would be 18446744073709551615 moves.

Not the answer you are looking for?

Search for more explanations.

Ask your own question