TowerOfHanoi

TowerOfHanoi - if(count> 0 moveDisks(count-1 needle1...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//Recursion: TowerOfHanoi / public class TowerOfHanoi { public static void main(String[] args) { System.out.println("Moves for 3 disk problem"); moveDisks(3, 1, 3, 2); } public static void moveDisks(int count, int needle1, int needle3, int needle2)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { if (count > 0) { moveDisks(count-1, needle1, needle2, needle3); System.out.println("Move disk " + count + " from needle " + needle1 + " to needle " + needle3 + "."); moveDisks(count-1, needle2, needle3, needle1); } } }...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online