1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
oee [108]
3 years ago
12

Prepare a algorithm visualization for the Tower of Hanoi when 4 disks are to be moved from spindle #1 to spindle #3.

Computers and Technology
1 answer:
Setler [38]3 years ago
6 0

Answer:

follwing is the code for Tower of Hanoi for n disks.

#include <iostream>

using namespace std;

void towofhan(int n,char source,char aux,char dest)//function for tower of hanoi..

{

if(n<0)

return ;

   if(n==1)//base case.

   {

       cout<<"Move disk 1 from "<<source<<" to spindle "<<dest<<endl;

       return;

   }

   towofhan(n-1,source,dest,aux);//recursive call.

   cout<<"move disk "<<n<<" from "<<source<<" to spindle "<<dest<<endl;

   towofhan(n-1,aux,source,dest);//recursive call.

}

int main() {

   int n=4;

   towofhan(n,'1','2','3');//function call.

   return 0;

}

Explanation:

If there is only 1 disk then we have to move the disk from source to destination.

Then after that we will apply recursion to solve the problem.

We have to work on only nth disk else will be done by the recursion.

First call recursion to move n-1 disks from source to auxiliary.

Then move nth disk from source to destination spindle.

Now move n-1 disks that are on the auxiliary spindle to destination spindle.

You might be interested in
Which unknown factor affects prices in the financial markets?
telo118 [61]

Answer:

There are four major factors that cause both long-term trends and short-term fluctuations. These factors are government, international transactions, speculation and expectation and supply and demand.

Explanation:

5 0
3 years ago
Networking device converts analog signals to digital ones?
iren2701 [21]

Solution:

An analog-to-digital converter, or ADC as it is more commonly called, is a device that converts analog signals into digital signals. Analog information is transmitted by modulating a continuous transmission signal by amplifying a signal's strength or varying its frequency to add or take away data.

This is the required answer.

5 0
3 years ago
When you started the vi editor, you forgot to specify the name for the new file you are creating. To save steps next time, how c
zysi [14]
Vi ‘filename’
For example file called main.py
vi main.py
8 0
3 years ago
The term that refers to the standard computer language for creating web pages is called:
Pavel [41]

Answer:

Language programming Web's programming language

Explanation:

6 0
4 years ago
Write a method __repr__(self) that returns a string representing an AIPlayer object. This method will override/replace the __rep
STatiana [176]

Answer:

def __repr__(self):

   s = '' "

   for row in range(self.height):

       s += '|'

       for column in range(self.width):

           s += self.slots[row][column] + '|'  + '\n'  + (2*self.width +1)*'-'  + '\n' + ' '+str(column%10)

   return s

Explanation:

The __repr__(self) method in python's object-oriented programming is a magic method used to print an output that represent the object instance of a class.

8 0
3 years ago
Other questions:
  • An “AI” (artificial intelligence) could be used in:
    10·1 answer
  • 7.14 LAB: Word frequencies Write a program that reads a list of words. Then, the program outputs those words and their frequenci
    10·1 answer
  • Match the spreadsheet features with their respective descriptions.
    9·2 answers
  • When a user runs an application, what transfers from a storage device to memory?
    15·1 answer
  • Which of the following statements about computer graphics formats is true?
    14·1 answer
  • You have created a new DHCP scope with address range 192.168.1.1 to 192.168.1.254. You have five servers configured with static
    8·1 answer
  • (Bible)<br> Sin may be an inward thought or an outward act. True False
    11·2 answers
  • Does anyone know how to do Python Essentials 5.7.1.6 because i am completely lost
    5·1 answer
  • The four differences between binary and denary​
    13·1 answer
  • On the new iOS version, can you save photos from ‘review confirmed photos’? If so, how? Thanks!
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!