Skip to content

Commit 0443409

Browse files
authored
Update TowerOfHanoi.cpp
1 parent 44cea4a commit 0443409

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

DSA 450 GFG/TowerOfHanoi.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@
99
#include<iostream>
1010
using namespace std;
1111

12-
void towerofHanoi(int n, char src, char helper ,char dest){
12+
void towerofHanoi(int n, char src, char helper ,char dest){// number of element , source, helper, destination
1313

1414

1515
if(n==0){
1616
return; //base case
1717
}
1818

19-
towerofHanoi(n-1, src, dest, helper);
19+
towerofHanoi(n-1, src, dest, helper);// Move n-1 disks from source to helper
2020
cout<<"Move from "<<src<<" to "<<helper<<endl;
21-
towerofHanoi(n-1, dest, helper, src);
21+
towerofHanoi(n-1, dest, helper, src);// Move n-1 disks from destination to helper
2222

2323

2424

2525
}
2626

2727
int main(){
2828

29-
towerofHanoi(3, 'A', 'B', 'C');
29+
towerofHanoi(3, 'A', 'B', 'C');// A = Source , B = helper, C = destination.
3030

3131
return 0;
3232

0 commit comments

Comments
 (0)