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
A water skier leaves the end of an 8 foot tall ski ramp with a speed of 20 mi/hr and at an angle of 250. He lets go of the tow r
klemol [59]

Answer:

At highest point:

y1 = 10.4 ft

v1 = (26.5*i + 0*j) ft/s

When he lands:

x2 = 31.5 ft (distance he travels)

t2 = 1.19 s

V2 = (26.5*i - 25.9*j) ft/s

a2 = -44.3°

Explanation:

Since he let go of the tow rope upon leaving the ramp he is in free fall from that moment on. In free fall he is affected only by the acceleration of gravity. Gravity has a vertical component only, so the movement will be at constant acceleration in the vertical component and at constant speed in the horizontal component.

20 mi / h = 29.3 ft/s

If the ramp has an angle of 25 degrees, the speed is

v0 = (29.3 * cos(25) * i + 29.3 * sin(25) * j) ft/s

v0 = (26.5*i + 12.4*j) ft/s

I set up the coordinate system with the origin at the base of the ramp under its end, so:

R0 = (0*i + 8*j) ft

The equation for the horizontal position is:

X(t) = X0 + Vx0 * t

The equation for horizontal speed is:

Vx(t) = Vx0

The equation for vertical position is:

Y(t) = Y0 + Vy0 * t + 1/2 * a * t^2

The equation for vertical speed is:

Vy(t) = Vy0 + a * t

In this frame of reference a is the acceleration of gravity and its values is -32.2 ft/s^2.

In the heighest point of the trajectory the vertical speed will be zero because that is the point where it transitions form going upwards (positive vertical speed) to going down (negative vertical speed), and it crosses zero.

0 = Vy0 + a * t1

a * t1 = -Vy0

t1 = -Vy0 / a

t1 = -12.4 / -32.2 = 0.38 s

y1 = y(0.38) = 8 + 12.4 * 0.38 + 1/2 * (-32.2) * (0.38)^2 = 10.4 ft

The velocity at that moment will be:

v1 = (26.5*i + 0*j) ft/s

When he lands in the water his height is zero.

0 = 8 + 12.4 * t2 + 1/2 * (-32.2) * t2^2

-16.1 * t2^2 + 12.4 * t2 + 8 = 0

Solving this equation electronically:

t2 = 1.19 s

Replacing this time on the position equation:

X(1.19) = 26.5 * 1.19 = 31.5 ft

The speed is:

Vx2 = 26.5 ft/s

Vy2 = 12.4 - 32.2 * 1.19 = -25.9 ft/s

V2 = (26.5*i - 25.9*j) ft/s

a2 = arctg(-25.9 / 26.5) = -44.3

3 0
3 years ago
How has drafting evolved in the 21st century
Mila [183]

Drafting has been around a long time. We can safely assume that since we’ve had a tool in our hands, we’ve been describing plans and technical representations and doodling ideas. Let’s take a closer aspect at drafting and its advance from an under-the-radar part of the method to a very developed skill set.

<u>Explanation</u>

•  1970s – The beginning computer-aided design systems were included in the industry. Following the design engineers tried the learning curve of using CAD, their performance and productivity went through the roof. Over time, CAD software became affordable and more user-friendly, and its fame grew.

•   1990s – CAD software was expanded further to include 3-D characteristics, and quickly the technical designs of the past enhanced increasingly simulated and accessible to engineer.

•   Present – The development of drafting has brought us to the present day, were using 3-D representations is the standard and the aim to generate full virtual prototypes.

8 0
3 years ago
Which basic principle influences how all HVACR systems work?
bezimeni [28]

Answer:

B) An increase in pressure can lower the boiling point of a liquid and change the temperature at which it turns to a gas.

Explanation:

B) An increase in pressure can lower the boiling point of a liquid and change the temperature at which it turns to a gas.

6 0
3 years ago
A clean machine is a _______________ machine.
solniwko [45]
A clean machine is a clean machine :-)
4 0
2 years ago
Which of the following can minimize engine effort and
son4ous [18]
It’s D. This is because having oil changes often, makes the care for your car better. I hope this helps.
7 0
2 years ago
Read 2 more answers
Other questions:
  • What is a two stroke engine and what is a four stroke engine, please keep the definitions as simple as can be and please explain
    8·2 answers
  • What kind of volcano usually forms over a hot spot?
    15·2 answers
  • A 150-lbm astronaut took his bathroom scale (a spring scale) and a beam scale (compares masses) to the moon where the local grav
    13·1 answer
  • Water of dynamic viscosity 1.12E-3 N*s/m2 flows in a pipe of 30 mm diameter. Calculate the largest flowrate for which laminar fl
    13·1 answer
  • Write a program that uses while loops to perform the following steps: Step a: Prompt the user to input two integers: firstNum an
    12·1 answer
  • What does the current in a semi-conductor is produced by?
    15·2 answers
  • According to the article, what is one reason why commercial carmakers aim to develop driverless technology?
    9·1 answer
  • Guyss I seriously and urgently need help what are the steps to build a headgear ??​
    5·2 answers
  • What subject is he......... now? Vietnamese.A. to learnB. learnC. learningD. learned
    10·1 answer
  • Read the passage.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!