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
Aleks04 [339]
3 years ago
6

Bob and Alice are solving practice problems for CSE 2320. They look at this code: for(i = 1; i <= N; i = (i*2)+17 ) for(k = i

+1; k <= i+N; k = k+1) // notice i in i+1 and i+N printf("B"); Alice says the loops are dependent. Bob says they are not dependent. Who is correct? ____________ What do you think? Are they dependent or not dependent? They are __________
Engineering
2 answers:
MissTica3 years ago
8 0

Answer:

Alice is correct.

The loop are dependent.

Explanation:

for(i = 1; i <= N; i = (i*2)+17 )

for(k = i+1; k <= i+N; k = k+1) // notice i in i+1 and i+N

printf("B")

This is a nested for-loop.

After the first for-loop opening, there is no block of statement to be executed rather a for-loop is called again. And the second for-loop uses the value of i from the first for-loop. The value of N is both called from outside the loop.

So, the second for-loop depend on the first for loop to get the value of i. For clarity purpose, code indentation or use of curly brace is advised.

ZanzabumX [31]3 years ago
4 0
<h2>Answer:</h2>

Alice is correct

They are dependent

<h2>Explanation:</h2><h2></h2>

<em>The code snippet can be re-written as follows;</em>

<em></em>

for(i = 1; i <= N; i = (i*2)+17 )

  for(k = i+1; k <= i+N; k = k+1)

<em>Which can also be re-written as;</em>

<em></em>

for(i = 1; i <= N; i = (i*2)+17 ) {

   for(k = i+1; k <= i+N; k = k+1){

   }

}

In many programming languages, curly brackets are used for grouping blocks of codes. For a for loop, while loop, if statement and other related control structures, the lines of statement(s) inside their curly brackets are executed when they are encountered. In the case where any of these control statements is written without curly brackets, the next line of code (and that only) following it belongs to its block.  

Consequential from the foregoing, at each of cycles of the <em>outer</em> <em>for loop</em> in the first code snippet above, the <em>inner for loop </em>will be executed. In other words, the inner for loop belongs to the block of the outer for loop though there is no curly bracket included. This also means that once a control statement has only a single line of code to be executed or to be a part of its block, curly brackets are not required. Therefore, the two versions of code snippets written above are identical and equivalent.

With the aforementioned, it is easy to say and see that the Alice is correct that the loops are dependent on each other.

You might be interested in
Air flows through a 0.25-m-diameter duct. At the inlet the velocity is 300 m/s, and the stagnation temperature is 90°C. If the M
Naddika [18.5K]

Answer:

a. 318.2k

b. 45.2kj

Explanation:

Heat transfer rate to an object is equal to the thermal conductivity of the material the object is made from, multiplied by the surface area in contact, multiplied by the difference in temperature between the two objects, divided by the thickness of the material.

See attachment for detailed analysis

7 0
3 years ago
Comparison of density values determines whether an item will float or sink in water. For each of the values below, determine the
geniusboy [140]

Answer:

a) the object floats

b) the object floats

c) the object sinks

Explanation:

when an object is less dense than in the fluid in which it is immersed, it will float due to its weight and volume characteristics, so to solve this problem we must find the mass and volume of each object in order to calculate the density and compare it with that of water

a)

volumen for a cube

V=L^3

L=1.53in=0.0388m

V=0.0388 ^3=5.8691x10^-5m^3=58.69ml

density=m/v

density=13.5g/58.69ml=0.23 g/ml

The wooden block floats  because it is less dense than water

b)

m=111mg=0.111g

density=m/v

density=0.111g/0.296ml=0.375g/ml

the metal paperclip floats   because it is less dense than water

c)

V=0.93cups=220.0271ml

m=0.88lb=399.1613g

Density=m/v

density=399.1613/220.027ml=1.8141g/ml

the apple sinks   because it is  denser than water

4 0
3 years ago
Consider this example of a recurrence relation. A police officer needs to patrol a gated community. He would like to enter the g
SashulF [63]

Answer:

the police officer cruise each streets precisely once and he enters and exit with the same gate.

Explanation:

NB: kindly check below for the attached picture.

The term ''Euler circuit'' can simply be defined as the graph that shows the edge of K once in a finite way by starting and putting a stop to it at the same vertex.

The term "Hamiltonian Circuit" is also known as the Hamiltonian cycle which is all about a one time visit to the vertex.

Here in this question, the door is the vertex and the road is the edge.

The information needed to detemine a Euler circuit and a Hamilton circuit is;

"the police officer cruise each streets precisely once and he enters and exit with the same gate."

Check attachment for each type of circuit and the differences.

7 0
3 years ago
Water flows through a pipe and enters a section where the cross sectional area is larger. Viscosity, friction, and gravitational
BaLLatris [955]

Answer:

(A) and (D)

Explanation:

1) P2 is less than P1, that is when P1 increases in pressure, the velocity V1 of the water also increases. Therefore, on the other hand, since P2 is directly proportional to V1, P2 and V2 will be less than P1 and V1 respectively.

2) For P2 greater than P1 and V2 also is greater than V1. Since P2 is directly proportional to V2, hence, when P2 increases in pressure, P1 reduces in pressure. Similarly, velocity, V2 also increases and V1 reduces.

3 0
3 years ago
An asphalt concrete mixture includes 94% aggregate by weight. The specific gravities of aggregate and asphalt are 2.65 and 1.0,
garik1379 [7]

Answer:

2.0%

Explanation:

Percentage of aggregate = 94%

Specific gravity = 2.65

Specific gravity of asphalt = 1.9

Density of mix = 147pcf = 147lb/ft³

Total weight of mix: (volume = 1ft³)

= (147lb/ft³)(1ft³)

= 147lb

Percentage weight of asphalt in<u> mix:</u>

100% - 94%

= 6%

Weight of asphalt binders

= 6% x 147lb

= 8.82lb

Weight of aggregate in mix:

= 94% x 147

= 138.18lb

Specific weight of asphalt binder:

(Gab)(Yw)

Yw = specific Weight of water

= 62.4lb

Gab = specific gravity of asphalt binder

= 1.0

(62.4lb)(1.0)

= 62.4 lb/ft³

Volume of asphalt in binder:

8.82/62.4

= 0.14ft³

Specific weight of binder in mix:

2.65 x 62.4lb/ft³

= 165.36 lb/ft³

Volume of aggregate:

= 138.18/165.36

= 0.84ft³

Volume of void in the mix:

1ft³ - 0.84ft³ - 0.14ft³

= 0.02ft³

<u>The percentage of void in total mix:</u>

VTM = (0.02ft³/1ft³)100

= 2.0%

8 0
3 years ago
Other questions:
  • Sometimes, steel studs may not be used on outside walls because they are?
    13·1 answer
  • What are the challenges posed by strategic information systems, and how should they be addressed?
    10·1 answer
  • What kind of energy transformation happens when a boy uses energy from a sandwich to run a race​
    11·2 answers
  • A sleeve made of SAE 4150 annealed steel has a nominal inside diameter of 3.0 inches and an outside diameter of 4.0 inches. It i
    9·2 answers
  • Wastewater flows into a _________ once it is released into a floor drain.
    8·1 answer
  • 2.4 kg of nitrogen at an initial state of 285K and 150 kPa is compressed slowly in an isothermal process to a final pressure of
    8·1 answer
  • Create a Python program that will produce the following output:
    7·1 answer
  • A fine-grained soil has a liquid limit of 200%, determined from the Casagrande cup method. The plastic limit was measured by rol
    15·1 answer
  • Why does the compression-refrigeration cycle have a high-pressure side and a low-pressure side?
    7·1 answer
  • I need help with this question
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!