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
There are two identical oil tanks. The level of oil in Tank A is 12 ft and is drained at the rate of 0.5 ft/min. Tank B contains
Luba_88 [7]

Answer:

  16 minutes

Explanation:

This is an example of a class of problems in which two quantities start with different initial values and change at different rates. In such problems, the rates of change are generally ones that cause the values to converge.

The question usually asks when the values will be the same. The generic answer is, "when the difference in rates makes up the difference in initial values."

Here the tanks differ in initial fill height by 12 -8 = 4 ft. The rates of change differ by 0.5 -0.25 = 0.25 ft/min. The more filled tank is draining faster (important), so the fill heights will converge after ...

  (4 ft)/(0.25 ft/min) = 16 min

The level in the two tanks will be the same after 16 minutes.

__

<em>Additional comment</em>

The oil levels at that time will be 4 ft.

You can write two equations for height:

  y = 12 -0.5x . . . . . . . height in feet after x minutes (tank A)

  y = 8 -0.25x . . . . . .  height in feet after x minutes (tank B)

These will be equal when ...

  y = y

  12 -0.5x = 8 -0.25x

  4 = 0.25x . . . . . . . . . . add 0.5x -8

  16 = x . . . . . . . . . . . . multiply by 4 . . . . time to equal height

The graph shows when the tanks will have equal heights and when they will be drained.

4 0
2 years ago
What causes the moon to be illuminated? PLEASE HELP MEH ILL GIVE YOU BRAINLEIST!!
Likurg_2 [28]

Answer:

D Reflection

Explanation:

It reflects the light from the sun. Then when the earth gets in the way, it casts a shadow causing crescent moons.

7 0
2 years ago
2. A thin vertical panel L = 3 m high and w = 1.5 m wide is thermally insulated on one side and exposed to a solar radiation flu
n200080 [17]

Answer: 383.22K

Explanation:

L = 3m, w = 1.5m

Area A = 3 x 1.5 = 4.5m2

Q' = 750W/m2 (heat from sun) ,

& = 0.87

Q = &Q' = 0. 87x750 = 652.5W/m2

E = QA = 652.5 x 4.5 = 2936.25W

T(sur) = 300K, T(panel) = ?

Using E = §€A(T^4(panel) - T^4(sur))

§ = Stefan constant = 5.7x10^-8

€ = emmisivity = 0.85

2936.25 = 5.7x10^-8 x 0.85 x 4.5 x (T^4(panel) - 300^4)

T(panel) = 383.22K

See image for further details.

5 0
3 years ago
A rigid 14-L vessel initially contains a mixture of liquid water and vapor at 100°C with 12.3 percent quality. The mixture is th
tigry1 [53]

Answer:

Q = 65.388 KJ

Explanation:

To calculate the heat required for the given process Q, we recall the energy balance equation.

Therefore, : Q = Δ U = m (u₂ - u₁) ..................equation (1)

We should note that there are no kinetic or potential energy change so the heat input in the system is converted only to internal energy.

Therefore, we will start the equation with the mass of the water (m) using given the initial percentage quality as x₁ = 0.123 and initial temperature t₁ = 100⁰c , we can them determine the initial specific volume v₁ of the mixture. For the calculation, we will also need the specific volume of liquid vₙ  = 0.001043m³/kg and water vapour (vₐ) = 1.6720m³/kg

Therefore, u₁ = vₙ + x₁ . ( vₐ - vₙ)

                   u₁ = 0.001043m³/kg + 0.123 . ( 1.6720m³/kg - 0.001043m³/kg)

                   u₁ = 0.2066m³/kg

Moving forward, the mass of the vapor can then be calculated using the given volume of tank V = 14 L but before the calculation, we need to convert the volume to from liters to m³.

Therefore, V = 14L . 1m² / 1000L = 0.014 m³

Hence, m = V / u₁

                 0.014m³ / 0.2066 m³/kg

              m = 0. 0677 kg

Also, the initial specific internal energy u₁ can be calculated using the given the initial given quality of x₁ , the specific internal energy of liquid water vₐ = 419.06 kj / kg and the specific internal energy of evaporation vₐₙ = 2087.0 kj/kg.

Therefore, u₁ = vₐ + x₁ . vₐₙ

                   u₁ = 419.06 kj / kg + 0.123  .  2087.0 kj/kg

                    u₁ = 675.76 kj/kg

For the final specific internal energy u₂, we first need to calculate the final quality of the mixture x₂ . The tank is rigid meaning the volume does not change and it is also closed meaning the mass does not change.from this, we can conclude the the specific volume also does not change during the process u₁ = u₂. This allows us to use the given final temperature T₂ = 180⁰c to determine the final quality x₂ of the mixture. for the calculation, we will also need the specific volume of liquid vₙ=0.001091m³/kg and vapor vₐ =  0.39248m³/kg

Hence, x₂ = u₂ - vₙ / uₐ

x₂ = 0.2066 m³/kg - 0.001091m³/kg / 0.39248m³/kg

x₂ = 0.524

Moving forward to calculate the final internal energy u₂, we have :

u₂ = vₙ + x₂ . vₙₐ

u₂ = 631.66 kj/kg + 0.524  . 1927.4 kj/kg

u₂ = 1641.62 kj/kg

We now return to equation (1) to plug in the values generated thus far

Q = m (u₂ - u₁)

0. 0677 kg ( 1641.62 kj/kg - 675.76 kj/kg)

Q = 65.388KJ

7 0
3 years ago
Read 2 more answers
PLEASE ANSWER ASAP!
Butoxors [25]

Answer:

Please check the explanation.

Explanation:

While driving, white lines would require us to stay within the lane, also marking the shoulder of the roadway.

While yellow lines generally mark the center of a two-way road being used for two-way traffic.

We generally can pass on a two-way road if the yellow centerline is broken.

7 0
2 years ago
Read 2 more answers
Other questions:
  • The inlet and exhaust flow processes are not included in the analysis of the Otto cycle. How do these processes affect the Otto
    6·1 answer
  • The title block generally contains ________.
    12·1 answer
  • Consider a voltage v = Vdc + vac where Vdc = a constant and the average value of vac = 0. Apply the integral definition of RMS t
    7·1 answer
  • What type of drawing would civil engineers use if they needed to show an
    11·1 answer
  • The Hoover Dam is 221 m tall and 379 m wide. Approximating it as a flat plate, determine the effective resultant force on the da
    6·1 answer
  • Air at 40C flows over a 2 m long flat plate with a free stream velocity of 7 m/s. Assume the width of the plate (into the paper)
    9·1 answer
  • An Otto cycle with air as the working fluid has a compression ratio of 8.2. Under cold air standard conditions, what is the ther
    14·1 answer
  • The production of carbon dioxide makes it unwise and unsafe to operate a tractor or any motor vehicle inside enclosed spaces suc
    13·1 answer
  • Bridging are members installed periodically between joists to ensure which of the following?
    7·1 answer
  • In a lab, scientists grew several generations of offspring of a plant using the method shown. What conclusion can you make about
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!