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
Lorico [155]
3 years ago
15

The way most recursive functions are written, they seem to be circular at first glance, defining the solution of a problem in te

rms of the problem itself ("A rose is a rose is a rose"). For example, a recursive function to compute the factorial of n might look like this:
Engineering
1 answer:
EastWind [94]3 years ago
6 0

Question Continuation

int factorial(int n) {

if(n == 0)

return 1;

else

return n * factorial(n - 1);

}

Provide a brief explanation why this recursive function works.

Show all steps involved in calculating factorial(3) using the function defined.

Answer:

1. Brief explanation why this recursive function works.

First, the recursive method factorial is defined.

This is the means through with the machine identifies the method.

The method is defined as integer, the machine will regard it as integer.

When the factorial is called from anywhere that has access to it, which in this case is within the factorial class itself. This means you can call it from the main method, or you can call it from the factorial method itself. It's just a function call that, well, happens to call itself.

2. Steps to calculate factorial(3)

1 First, 3 is assigned to n.

2. At line 2, the machine checks if n equals 0

3. If yes, the machine prints 1

4. Else; it does the following from bottom to top

factorial(3):

return 3*factorial(2);

return 2*factorial(1):

return 1;

Which gives 3 * 2 * 1 = 6

5. Then it prints 6, which is the result of 3!

You might be interested in
You are using a Geiger counter to measure the activity of a radioactive substance over the course of several minutes. If the rea
Reika [66]

Answer: 33.35 minutes

Explanation:

A(t) = A(o) *(.5)^[t/(t1/2)]....equ1

Where

A(t) = geiger count after time t = 100

A(o) = initial geiger count = 400

(t1/2) = the half life of decay

t = time between geiger count = 66.7 minutes

Sub into equ 1

100=400(.5)^[66.7/(t1/2)

Equ becomes

.25= (.5)^[66.7/(t1/2)]

Take log of both sides

Log 0.25 = [66.7/(t1/2)] * log 0.5

66.7/(t1/2) = 2

(t1/2) = (66.7/2 ) = 33.35 minutes

4 0
3 years ago
Compute the volume percent of graphite, VGr, in a 3.2 wt% C cast iron, assuming that all the carbon exists as the graphite phase
Yanka [14]

Answer:

The volume percentage of graphite is 10.197 per cent.

Explanation:

The volume percent of graphite is the ratio of the volume occupied by the graphite phase to the volume occupied by the graphite and ferrite phases. The weight percent in the cast iron is 3.2 wt% (graphite) and 96.8 wt% (ferrite). The volume percentage of graphite is:

\%V_{gr} = \frac{V_{gr}}{V_{gr}+V_{fe}} \times 100\,\%

Where:

V_{gr} - Volume occupied by the graphite phase, measured in cubic centimeters.

V_{fe} - Volume occupied by the graphite phase, measured in cubic centimeters.

The expression is expanded by using the definition of density and subsequently simplified:

\%V_{gr} = \frac{\frac{m_{gr}}{\rho_{gr}} }{\frac{m_{gr}}{\rho_{gr}}+\frac{m_{fe}}{\rho_{fe}}}\times 100\,\%

Where:

m_{fe}, m_{gr} - Masses of the ferrite and graphite phases, measured in grams.

\rho_{fe}, \rho_{gr} - Densities of the ferrite and graphite phases, measured in grams per cubic centimeter.

\%V_{gr} = \frac{1}{1+\frac{\frac{m_{fe}}{\rho_{fe}} }{\frac{m_{gr}}{\rho_{gr}} } }\times 100\,\%

\%V_{gr} = \frac{1}{1 + \left(\frac{\rho_{gr}}{\rho_{fe}} \right)\cdot\left(\frac{m_{fe}}{m_{gr}} \right)} \times 100\,\%

If \rho_{gr} = 2.3\,\frac{g}{cm^{3}}, \rho_{fe} = 7.9\,\frac{g}{cm^{3}}, m_{gr} = 3.2\,g and m_{fe} = 96.8\,g, the volume percentage of graphite is:

\%V_{gr} = \frac{1}{1+\left(\frac{2.3\,\frac{g}{cm^{3}} }{7.9\,\frac{g}{cm^{3}} } \right)\cdot \left(\frac{96.8\,g}{3.2\,g} \right)} \times 100\,\%

\%V_{gr} = 10.197\,\%V

The volume percentage of graphite is 10.197 per cent.

5 0
3 years ago
In normal operation, a paper mill generates excess steam at 20 bar and 400◦C. It is planned to use this steam as the feed to a t
Keith_Richards [23]

Answer:

The maximum power that can be generated is 127.788 kW

Explanation:

Using the steam table

Enthalpy at 20 bar = 2799 kJ/kg

Enthalpy at 2 bar = 2707 kJ/kg

Change in enthalpy = 2799 - 2707 = 92 kJ/kg

Mass flow rate of steam = 5000 kg/hr = 5000 kJ/hr × 1 hr/3600 s = 1.389 kg/s

Maximum power generated = change in enthalpy × mass flow rate = 92 kJ/kg × 1.389 kg/s = 127.788 kJ/s = 127.788 kW

6 0
3 years ago
8.19 - Airline Reservations System (Project Name: Airline) - A small airline has just purchased a computer for its new automated
e-lub [12.9K]

Answer:

The App is written in C++ language using dev C++.

Explanation:

/******************************************************************************

You can run this program in any C++ compiler like dev C++ or any online C++ compiler

*******************************************************************************/

#include <iostream>

using namespace std;

class bookingSeat// class for airline reservation system

{

  private:

   

   

  bool reserveSeat[10];// 10 seats (1-5) for first class and 6-10 for economy class

  int firstClassCounter=0;//count first class seat

  int economyClassCounter=5;//count economy class seat

  char seatPlacement;/* switch between economy and first clas seat----- a variable for making decision based on user input*/

  public:  

  void setFirstClassSeat()//

  {

      if(firstClassCounter<5)// first class seat should be in range of 1 to 5

      {

          reserveSeat[firstClassCounter]=1; /*set first class seat..... change index value to 1 meaning that it now it is reserved*/

          cout<<"Your First Class seat is booked and your seat no is "<<firstClassCounter+1; //display seat number reserved

          firstClassCounter++; //increament counter

      }

      else//in case seats are ful

      {

          cout<<"\nSeats are full";

          if(economyClassCounter==10 && firstClassCounter==5)

          {

              cout<<"\n Next flight leaves in 3 hours.";

          }

          else

          {

              cout<<"\nIt’s acceptable to be placed to you in the first-class section  y/n ";//take input from user

              cin>>seatPlacement;//user input

              if(seatPlacement=='y')//if customer want to reserve seat in first class

              {

                  setEconomyClassSeat();// then reserve first class seat

              }

              else

              {

                  cout<<"\n Next flight leaves in 3 hours.";

               }

               

          }

      }

       

  }

  void setEconomyClassSeat()//set economy class seat

  {

    if(economyClassCounter<10)//seat ranges between 6 and 10

      {

          reserveSeat[economyClassCounter]=1;// reserve economy class seat

          cout<<"Your Economy class seat is booked and your seat no is "<<economyClassCounter+1;//display reservation message about seat

          economyClassCounter++;//increament counter

      }

      else// if economy class seats are fulled

      {

          cout<<"\nSeats are full";

          if(economyClassCounter==10 && firstClassCounter==5)//check if all seats are booked in both classes

          {

              cout<<"\n Next flight leaves in 3 hours.";

          }

          else

          {

              cout<<"\nIt’s acceptable to be placed to you in the first-class section  y/n ";//take input from user

              cin>>seatPlacement;//user input

              if(seatPlacement=='y')//if customer want to reserve seat in first class

              {

                  setFirstClassSeat();// then reserve first class seat

              }

              else

              {

                  cout<<"\n Next flight leaves in 3 hours.";

               }

               

          }

      }

  }

   

   

};

int main()

{   int checkseat=10;// check seat

   int classType;//class type economy or first class

   bookingSeat bookseat;//object declaration of class bookingSeat

   while(checkseat<=10)//run the application until seats are fulled in both classes

   {

       cout<<"\nEnter 1 for First Class and 2 for Economy Class ";

       cin>>classType;//what user entered

       switch (classType)//decide which seat class to be reserved  

       {

           case 1://if user enter 1 then reserve first class seat

           bookseat.setFirstClassSeat();

           break;

           case 2://if user enter 2 then reserve the economy class seat

           bookseat.setEconomyClassSeat();

           

       }

       

   }

   

   return 0;

}

8 0
3 years ago
Proper ventilation is required when welding, so that you don't ____________.
galben [10]
I say the answers is A but if you mean ventilation in the area of the room then answer B
4 0
3 years ago
Read 2 more answers
Other questions:
  • Cng containers need to be inspected
    7·1 answer
  • A flocculation basin equipped with revolving paddles is 60 ft long (the direction of flow). 45 ft wide, and 14 ft deep and treat
    11·1 answer
  • Give two methods on how powder is produced in powder metallurgy.
    5·2 answers
  • Ok I need a new laptop but I'm not sure which one. The Surface laptop 3 is better in many fields like the camera, speaker, audio
    14·1 answer
  • When welding stick (SMAW) what is the distance between top of bare end of electrode and base metal?
    7·1 answer
  • A digital Filter is defined by the following difference equation:
    11·1 answer
  • If a person runs a distance of 0.7 km in 3 min, what is his average speed in kilometres/hour ​
    7·1 answer
  • Steel riverts in aluminium drain gutters leak after two years. is it galvanic corrosion? ​
    5·1 answer
  • When economist determine that a nations GDP has declined, they can point to this as a sign of what?
    8·1 answer
  • If an internally piloted DCV does not shift, you should use a gauge to _____. A.check the pilot line pressure b. check the inlet
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!