Skip to content

Commit c1ab3a7

Browse files
Adding TOWER OF HANOI to Recursion File
1 parent 0e8291e commit c1ab3a7

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.thealgorithms.recursion;
2+
public class TowerofHanoi{
3+
public static void towerofHanoi(int n,String src,String helper,String dest){
4+
if(n==1){
5+
System.out.println("Tranfer disk"+n+"from"+src+"to"+dest);
6+
return;
7+
}
8+
towerofHanoi(n-1, src, dest,helper);
9+
System.out.println("tranfer disk"+n+"from"+src+"to"+helper);
10+
towerofHanoi(n-1, helper,src,dest);
11+
}
12+
13+
}

0 commit comments

Comments
 (0)