05/25
Home
Generate Towers
Start
Tower A
Empty
icon
icon
Tower B
Empty
icon
icon
Tower C
Empty
icon
icon
From A to B 0
From B to C 0
From A to C 0
Total Swaps 0
A 0
B 0
C 0
Disc Count
Not Running
More About Tower Of Hanoi
1void towerOfHanoi(int n, char from_rod, char to_rod,char aux_rod)
2{
3	if (n == 0) {
4		return;
5	}
6	towerOfHanoi(n - 1, from_rod, aux_rod, to_rod);
7	cout << "Move disk " << n << " from rod " << from_rod << " to rod " << to_rod << endl;
8	towerOfHanoi(n - 1, aux_rod, to_rod, from_rod);
9}
Time Complexity
Best Case O(2^n)Average Case O(2^n)Worst Case O(2^n)
Space Complexity
Best Case O(n)Average Case O(n)Worst Case O(n)
Made with ❤️ by Rahul Biswakarma