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
Air enters a compressor steadily at the ambient conditions of 100 kPa and 22°C and leaves at 800 kPa. Heat is lost from the comp
telo118 [61]

Answer:

a) 358.8K

b) 181.1 kJ/kg.K

c) 0.0068 kJ/kg.K

Explanation:

Given:

P1 = 100kPa

P2= 800kPa

T1 = 22°C = 22+273 = 295K

q_out = 120 kJ/kg

∆S_air = 0.40 kJ/kg.k

T2 =??

a) Using the formula for change in entropy of air, we have:

∆S_air = c_p In \frac{T_2}{T_1} - Rln \frac{P_2}{P_1}

Let's take gas constant, Cp= 1.005 kJ/kg.K and R = 0.287 kJ/kg.K

Solving, we have:

[/tex] -0.40= (1.005)ln\frac{T_2}{295} ln\frac{800}{100}[/tex]

-0.40= 1.005(ln T_2 - 5.68697)- 0.5968

Solving for T2 we have:

T_2 = 5.8828

Taking the exponential on the equation (both sides), we have:

[/tex] T_2 = e^5^.^8^8^2^8 = 358.8K[/tex]

b) Work input to compressor:

w_in = c_p(T_2 - T_1)+q_out

w_in = 1.005(358.8 - 295)+120

= 184.1 kJ/kg

c) Entropy genered during this process, we use the expression;

Egen = ∆Eair + ∆Es

Where; Egen = generated entropy

∆Eair = Entropy change of air in compressor

∆Es = Entropy change in surrounding.

We need to first find ∆Es, since it is unknown.

Therefore ∆Es = \frac{q_out}{T_1}

\frac{120kJ/kg.k}{295K}

∆Es = 0.4068kJ/kg.k

Hence, entropy generated, Egen will be calculated as:

= -0.40 kJ/kg.K + 0.40608kJ/kg.K

= 0.0068kJ/kg.k

3 0
3 years ago
In contouring, it is necessary to measure position and not velocity for feedback.
EastWind [94]

Answer:

(1). False, (2). True, (3). False, (4). False, (5). True.

Explanation:

The term ''contouring'' in this question does not have to do with makeup but it has to deal with the measurement of all surfaces in planes. It is a measurement in which the rough and the contours are being measured. So, let us check each questions again.

(1). In contouring, it is necessary to measure position and not velocity for feedback.

ANSWER : b =>False. IT IS NECESSARY TO MEASURE BOTH FOR FEEDBACK.

(2). In contouring during 2-axis NC machining, the two axes are moved at the same speed to achieve the desired contour.

ANSWER: a=> True.

(3). Job shop is another term for process layout.

ANSWER: b => False

JOB SHOP IS A FLEXIBLE PROCESS THAT IS BEING USED during manufacturing process and are meant for job Production. PROCESS LAYOUT is used in increasing Efficiency.

(4). Airplanes are normally produced using group technology or cellular layout.

ANSWER: b => False.

(5). In manufacturing, value-creating time is greater than takt time.

ANSWER: a => True.

8 0
3 years ago
A 4-pole, 3-phase induction motor operates from a supply whose frequency is 60 Hz. calculate: 1- the speed at which the magnetic
DiKsa [7]

Answer:

The answer is below

Explanation:

1) The synchronous speed of an induction motor is the speed of the magnetic field of the stator. It is given by:

n_s=\frac{120f_s}{p}\\ Where\ p\ is \ the \ number\ of\ machine\ pole, f_s\ is\ the\ supply \ frequency\\and\ n_s\ is \ the \ synchronous\ speed(speed \ of\ stator\ magnetic \ field)\\Given: f_s=60\ Hz, p=4. Therefore\\\\n_s=\frac{120*60}{4}=1800\ rpm

2) The speed of the rotor is the motor speed. The slip is given by:

Slip=\frac{n_s-n_m}{n_s}. \\ n_m\ is\ the \ motor\ speed(rotor\ speed)\\Slip = 0.05, n_s= 1800\ rpm\\ \\0.05=\frac{1800-n_m}{1800}\\\\ 1800-n_m=90\\\\n_m=1800-90=1710\ rpm

3) The frequency of the rotor is given as:

f_r=slip*f_s\\f_r=0.04*60=2.4\ Hz

4) At standstill, the speed of the motor is 0, therefore the slip is 1.

The frequency of the rotor is given as:

f_r=slip*f_s\\f_r=1*60=60\ Hz

6 0
3 years ago
A timing light checks the ignition timing in relation to the ____ position.
kogti [31]

Answer:

The timing light is connected to the ignition circuit and used to illuminate the timing marks on the engine's crankshaft pulley or flywheel, with the engine running. The apparent position of the marks, frozen by the stroboscopic effect, indicates the current timing of the spark in relation to piston position.

Explanation:

:)

8 0
3 years ago
Write a C program that asks the user to enter two numbers, obtains the two numbers from the user and prints the sum, product, di
Bogdan [553]

Answer:

View Image

Explanation:

Initialize your variable as a float or double since you're going to be using fractions in your answer.

User scanf() to get user input.

Print out the sum, product, quotient, and difference between the two numbers.

8 0
3 years ago
Other questions:
  • Technician A says that you don’t need to use an exhaust extraction system when working on vehicles equipped with a catalytic con
    9·1 answer
  • A pipe of 10 cm inner diameter is used to send crude oil over distance of 400 meters. The entire pipe was laid horizontal. The v
    5·1 answer
  • A wastewater treatment plant has two primary clarifiers, each 20m in diameter with a 2-m side-water depth. the effluent weirs ar
    8·1 answer
  • Air expands through an ideal turbine from 1 MPa, 900 K to 0.1 MPa, 500K. The inlet velocity is small compared to the exit veloci
    10·1 answer
  • Yasir is trying to build an energy-efficient wall and deciding what materials to use. How can he calculate the thermal resistanc
    6·1 answer
  • The Greek alphabet has 24 distinct lowercase letters. How many bits are needed to be able to encode any single lowercase Greek l
    9·1 answer
  • All welding processes that take place without melting of the work pieces. a)- True b)-False
    15·1 answer
  • Users say that the game is interesting to look at but the music gets annoying
    9·1 answer
  • Steven is starting a project that requires a specialized, experienced contractor. Which selection process is the most suitable f
    11·1 answer
  • Select three types of lines that engineers use to help represent the shape of a design in a sketch.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!