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
AysviL [449]
3 years ago
11

Suppose you have two arrays: Arr1 and Arr2. Arr1 will be sorted values. For each element v in Arr2, you need to write a pseudo c

ode that will print the number of elements in Arr1 that is less than or equal to v. For example: suppose you are given two arrays of size 5 and 3 respectively. 5 3 [size of the arrays] Arr1 = 1 3 5 7 9 Arr2 = 6 4 8 The output should be 3 2 4 Explanation: Firstly, you should search how many numbers are there in Arr1 which are less than 6. There are 1, 3, 5 which are less than 6 (total 3 numbers). Therefore, the answer for 6 will be 3. After that, you will do the same thing for 4 and 8 and output the corresponding answers which are 2 and 4. Your searching method should not take more than O (log n) time. Sample Input Sample Output 5 5 1 1 2 2 5 3 1 4 1 5 4 2 4 2 5
Engineering
1 answer:
brilliants [131]3 years ago
6 0

Answer:

The algorithm is as follows:

1. Declare Arr1 and Arr2

2. Get Input for Arr1 and Arr2

3. Initialize count to 0

4. For i in Arr2

4.1 For j in Arr1:

4.1.1 If i > j Then

4.1.1.1 count = count + 1

4.2 End j loop

4.3 Print count

4.4 count = 0

4.5 End i loop

5. End

Explanation:

This declares both arrays

1. Declare Arr1 and Arr2

This gets input for both arrays

2. Get Input for Arr1 and Arr2

This initializes count to 0

3. Initialize count to 0

This iterates through Arr2

4. For i in Arr2

This iterates through Arr1 (An inner loop)

4.1 For j in Arr1:

This checks if current element is greater than current element in Arr1

4.1.1 If i > j Then

If yes, count is incremented by 1

4.1.1.1 count = count + 1

This ends the inner loop

4.2 End j loop

Print count and set count to 0

<em>4.3 Print count</em>

<em>4.4 count = 0</em>

End the outer loop

4.5 End i loop

End the algorithm

5. End

You might be interested in
Prompt the user to enter five numbers, being five people's weights. Store the numbers in an array of doubles. Output the array's
atroni [7]

Answer:

See below in the explanation section the Matlab script to solve the problem.

Explanation:

prompt='enter the first weight w1:  ';

w1=input(prompt);

wd1=double(w1);

prompt='enter the second weight w2:  ';

w2=input(prompt);

wd2=double(w2);

prompt='enter the third weight w3:  ';

w3=input(prompt);

wd3=double(w3);

prompt='enter the fourth weight w4:  ';

w4=input(prompt);

wd4=double(w4);

prompt='enter the first weight w5:  ';

w5=input(prompt);

wd5=double(w5);

x=[wd1 wd2 wd3 wd4 wd5]

format short

6 0
3 years ago
View the picture below and then correctly answer the questions using the following words: Temperate Zone, Tropical Zone, Polar Z
Nadusha1986 [10]

Can you provide the picture? Thanks !

8 0
3 years ago
Read 2 more answers
Which type of finish is absorbed into the wood?
stiks02 [169]
Penetrating finishes are absorbed by the wood and dry inside the wood. Interior wood stain is used to accentuate the grain in natural woods or plywood while still adding some color. While wood stains offer some level of protection on wood, it's recommended to use stain in combination with a surface finish.
7 0
3 years ago
Steam at 1400 kPa and 350°C [state 1] enters a turbine through a pipe that is 8 cm in diameter, at a mass flow rate of 0.1 kg⋅s−
sergeinik [125]

Answer:

Power output, P_{out} = 178.56 kW

Given:

Pressure of steam, P = 1400 kPa

Temperature of steam, T = 350^{\circ}C

Diameter of pipe, d = 8 cm = 0.08 m

Mass flow rate, \dot{m} = 0.1 kg.s^{- 1}

Diameter of exhaust pipe, d_{h} = 15 cm = 0.15 m

Pressure at exhaust, P' = 50 kPa

temperature, T' =  100^{\circ}C

Solution:

Now, calculation of the velocity of fluid at state 1 inlet:

\dot{m} = \frac{Av_{i}}{V_{1}}

0.1 = \frac{\frac{\pi d^{2}}{4}v_{i}}{0.2004}

0.1 = \frac{\frac{\pi 0.08^{2}}{4}v_{i}}{0.2004}

v_{i} = 3.986 m/s

Now, eqn for compressible fluid:

\rho_{1}v_{i}A_{1} = \rho_{2}v_{e}A_{2}

Now,

\frac{A_{1}v_{i}}{V_{1}} = \frac{A_{2}v_{e}}{V_{2}}

\frac{\frac{\pi d_{i}^{2}}{4}v_{i}}{V_{1}} = \frac{\frac{\pi d_{e}^{2}}{4}v_{e}}{V_{2}}

\frac{\frac{\pi \times 0.08^{2}}{4}\times 3.986}{0.2004} = \frac{\frac{\pi 0.15^{2}}{4}v_{e}}{3.418}

v_{e} = 19.33 m/s

Now, the power output can be calculated from the energy balance eqn:

P_{out} = -\dot{m}W_{s}

P_{out} = -\dot{m}(H_{2} - H_{1}) + \frac{v_{e}^{2} - v_{i}^{2}}{2}

P_{out} = - 0.1(3.4181 - 0.2004) + \frac{19.33^{2} - 3.986^{2}}{2} = 178.56 kW

4 0
2 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
Other questions:
  • To cool a summer home without using a vapor compression refrigeration cycle, air is routed through a plastic pipe (k=0.15 W/m*K,
    15·1 answer
  • Which phrases describe an irregular galaxy?
    8·1 answer
  • Vehicles arrive at a single toll booth beginning at 8:00 A.M. They arrive and depart according to a uniform deterministic distri
    9·1 answer
  • How much heat (Btu) is prod uced by a 150-W light bulb that is on for 20-hours?
    14·1 answer
  • Write a static method named fixSpacing that accepts a Scanner representing a file as a parameter and writes that file's text to
    5·1 answer
  • 4. What are the basic scientific principles the engineers who designed the digital scales would have needed to understand to des
    5·1 answer
  • What ic engine for mechanic
    15·1 answer
  • What three training organizations are important for Union Masons?
    14·1 answer
  • “In a trusting relationship, confidential information is kept confidential.” Explain what the limits to confidentiality are and
    14·1 answer
  • What two factors are changing when the current is changed on an electric generator
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!