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
Developed an automated program in any language which take 12 dependent variable and corresponding independent variables and show
otez555 [7]

Answer:

Explanation:

var generator = new Random(1);

// Now the nextGaussian() function returns a normal distribution of random numbers with the following parameters: a mean of zero and a standard deviation of one

var draw = function() {

var num = generator.nextGaussian();

var standardDeviation = 60;

var mean = 2003;

// Multiply by the standard deviation and add the mean.

var x = standardDeviation * num + mean;

noStroke();

fill(214, 159, 214, 10);

ellipse(x, 200, 16, 16); };

Hope this will be helpful

3 0
3 years ago
What is a radio wave made up of? Molecules? Electrons? Other?
mafiozo [28]

Radio waves are radiated by charged particles when they are accelerated. They are produced artificially by time-varying electric currents, consisting of electrons flowing back and forth in a specially-shaped metal conductor called an antenna. ... Radio waves are received by another antenna attached to a radio receiver.

4 0
3 years ago
Read 2 more answers
The welding method that requires the operator to observe and only make corrections is
SVEN [57.7K]
Automatic manual semiautomatic
3 0
3 years ago
Read 2 more answers
A pin fin of uniform cross-sectional area is fabricated of an aluminum alloy (k = 160W m-1 K-1 ). The fin diameter is D = 4 mm,
disa [49]

Answer: (a) 36.18mm

(b) 23.52

Explanation: see attachment

4 0
4 years ago
A motor is mounted on a platform that is observed to vibrate excessively at an operating speed of 6000 rpm producing a 250-N for
vichka [17]

Answer:

The amplitude of the absorbed mass can be found

for ka:

X_{a} =0.002m=\frac{F_{0} }{K_{a} } =\frac{250}{K_{a} } =125000N/m

now

w^2=\frac{K_{a} }{m_{a} } \\m_{a} =\frac{K_{a} }{w^2} =\frac{125000}{[6000*2\pi /60]^2} =0.317kg

4 0
3 years ago
Other questions:
  • Millions of years ago, the Sierra Nevada region began to be uplifted along a crack in Earth's crust. The region on the other sid
    14·1 answer
  • A soil had a liquid limit of 44, a plastic limit of 21, and a shrinkage limit of 14. In the summer, the in situ water content wa
    14·1 answer
  • A steam turbine receives 8 kg/s of steam at 9 MPa, 650 C and 60 m/s (pressure, temperature and velocity). It discharges liquid-v
    7·1 answer
  • Some engineers have developed a device that provides lighting to rural areas with no access to grid electricity. The device is i
    13·1 answer
  • In the designation of wrought Al alloys, eg. 3m, what does the first digit-3- refer to? A. The main alloying element B. Carbon p
    15·1 answer
  • Determine the time required for a car to travel 1 km along a road if the car starts from rest, reaches a maximum speed at some i
    10·1 answer
  • An open vat in a food processing plant contains 500 L of water at 20°C and atmospheric pressure. If the water is heated to 80°C,
    9·1 answer
  • 5) /
    12·1 answer
  • Give me uses of a grinding machine in agriculture.
    15·1 answer
  • PLZZZZZ HELP
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!