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
Andrej [43]
3 years ago
15

In details and step-by-step, show how you apply the Bubble Sort algorithm on the following list of values. Your answer should sh

ow all inner and outer loops entries in each pass of the sort algorithm (i.e. list all 5 numbers in pass one, then list all 5 numbers in pass two, then list all 5 numbers in pass three… etc.)19, 18, 25, 17, 12
Engineering
1 answer:
astraxan [27]3 years ago
6 0

( 12 17 18 19 25 )

<u>Explanation:</u>

<u>First Pass:</u>

( 19 18 25 17 12 ) –> ( 18 19 25 17 12 ), Here, algorithm compares the first two elements, and swaps since 19 > 18.

( 18 19 25 17 12 ) –> ( 18 19 25 17 12 ), Now, since these elements are already in order (25 > 19), algorithm does not swap them.

( 18 19 25 17 12 ) –> ( 18 19 17 25 12 ), Swap since 25 > 17

( 18 19 17 25 12 ) –> ( 18 19 17 12 25 ), Swap since 25 > 12

<u>Second Pass:</u>

( 18 19 17 12 25 ) –> ( 18 19 17 12 25 )

( 18 19 17 12 25 ) –> ( 18 17 19 12 25 ), Swap since 19 > 17

( 18 17 19 12 25 ) –> ( 18 17 12 19 25 ), Swap since 19 > 12

( 18 17 12 19 25 ) –> ( 18 17 12 19 25 )

<u>Third Pass:</u>

( 18 17 12 19 25 ) –> ( 17 18 12 19 25 ), Swap since 18 > 17

( 17 18 12 19 25 ) –> ( 17 12 18 19 25 ), Swap since 18 > 12

( 17 12 18 19 25 ) –> ( 17 12 18 19 25 )

( 17 12 18 19 25 ) –> ( 17 12 18 19 25 )

<u>Fourth Pass:</u>

( 17 12 18 19 25 ) –> ( 12 17 18 19 25 ), Swap since 17 > 12

( 12 17 18 19 25 ) –> ( 12 17 18 19 25 ), Swap since 18 > 12

( 12 17 18 19 25 ) –> ( 12 17 18 19 25 )

( 12 17 18 19 25 ) –> ( 12 17 18 19 25 )

Now, the array is already sorted, but our algorithm does not know if it is completed. The algorithm needs one whole pass without any swap to know it is sorted.

<u>Fifth Pass:</u>

( 12 17 18 19 25 ) –> ( 12 17 18 19 25 )

( 12 17 18 19 25 ) –> ( 12 17 18 19 25 )

( 12 17 18 19 25 ) –> ( 12 17 18 19 25 )

( 12 17 18 19 25 ) –> ( 12 17 18 19 25 )

You might be interested in
Determine the maximum volume in gallons​ [gal] of olive oil that can be stored in a closed cylindrical silo with a diameter of 3
Olin [163]

Answer:

V=1601gal

Explanation:

Hello! This problem is solved as follows,

First we must raise the equation that defines the pressure at the bottom of the tank with the purpose of finding the height that olive oil reaches.

This is given as the sum due to the atmospheric pressure (1atm = 101.325kPa), and the pressure due to the weight of the olive oil, taking into account the above, the following equation is inferred.

P=Poil+Patm

P=total pressure or absolute pressure=26psi=179213.28Pa

Patm= the atmospheric pressure =101325Pa

Poil=pressure due to the weight of olive oil=0.86αgh

α=density of water=1000kg/m^3

g=gravity=9.81m/s^2

h= height that olive oil reaches

solving

P=Poil+Patm

P=Patm+0.86αgh

h=\frac{P-Patm}{0.86\alpha g } =\frac{179214.28-101325}{(0.86)(1000)(9.81)} \\h=9.23m[/tex]

Now we can use the equation that defines the volume of a cylinder.

V=V=\frac{\pi }{4} D^{2} h

D=3ft=0.9144m

h=9.23m

solving

V=\frac{\pi }{4} (0.9144)^{2} 9.23=6.06m^3

finally we use conversion factors to find the volume in gallons

V=6.06m^3\frac{1000L}{1m^3} \frac{1gal}{3.785L} =1601gal

3 0
3 years ago
function summedValue = SummationWithLoop(userNum) % Summation of all values from 1 to userNum summedValue = 0; i = 1; % Write a
Alexeev081 [22]

Answer:

function summedValue = SummationWithLoop(userNum)

% Summation of all values from 1 to userNum

  summedValue = 0;

  i = 0;

  % use a while loop that assigns summedValue with the

  % sum of all values from 1 to userNum

  while(i <= userNum)

      summedValue = summedValue + i;

      i = i + 1;

  end

end

8 0
3 years ago
Worth 20 points! Please help ASAP!
gulaghasi [49]

Answer:

I am in 6th grade, why are high school things popping up??

Explanation:

8 0
3 years ago
A 7-hp (shaft) pump is used to raise water to an elevation of 15 m. If the mechanical efficiency of the pump is 82 percent, dete
Natali [406]

The maximum volume flow rate of water is determined as 0.029 m³/s.

<h3>Power of the pump</h3>

The power of the pump is watt is calculated as follows;

1 hp = 745.69 W

7 hp = ?

= 7 x 745.69 W

= 5,219.83 W

<h3>Mass flow rate of water</h3>

η = mgh/P

mgh = ηP

m = ηP/gh

m = (0.82 x 5,219.83)/(9.8 x 15)

m = 29.12 kg/s

<h3>Maximum volume rate</h3>

V = m/ρ

where;

  • ρ is density of water = 1000 kg/m³

V = (29.12)/(1000)

V = 0.029 m³/s

Learn more about volume flow rate here: brainly.com/question/21630019

#SPJ12

5 0
2 years ago
What is an air mass?​
kotegsom [21]

Answer:

An air mass is a body of air with horizontally uniform temperature, humidity, and pressure.

Explanation:

Because it is

8 0
3 years ago
Read 2 more answers
Other questions:
  • Determine the Thevenin/Norton Equivalent Circuit with respect to the terminalsa,bas shown in the figure. (Here 1A is an independ
    11·1 answer
  • WHAT IS A TOROID IN HYDRAULUCS?
    11·2 answers
  • One of our wifi network standards is IEEE 802.11ac. It can run at 6.77 Gbit/s data rate. Calculate the symbol rate for 801.11ac
    5·1 answer
  • 6
    5·1 answer
  • What energy type is represented in the picture?
    6·2 answers
  • B) Calculate the FS against uplift and calculate effoctive stress at the base level for water
    11·1 answer
  • ¿Cuál es el objetivo de la participación del gobierno en la economía?
    6·1 answer
  • Your sprayer has a 60-foot wide boom with 36 nozzles along this 60-foot length. Your spray speed is 4.5 miles per hour and you w
    15·1 answer
  • An ideal gas is contained in a closed assembly with an initial pressure and temperature of
    14·1 answer
  • How do you breed a linner?
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!