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
A fluid at 300 K flows through a long, thin-walled pipe of 0.2-m diameter. The pipe is enclosed in a concrete casing that is of
andrew-mc [135]

Answer:

The correct answer is "1341.288 W/m".

Explanation:

Given that:

T₁ = 300 K

T₂ = 500 K

Diameter,

d = 0.2 m

Length,

l = 1 m

As we know,

The shape factor will be:

⇒ SF=\frac{2 \pi l}{ln[\frac{1.08 b }{d} ]}

By putting the value, we get

⇒       =\frac{2 \pi l}{ln[\frac{1.08\times 1}{0.2} ]}

⇒       =3.7258 \ l

hence,

The heat loss will be:

⇒ Q=SF\times K(T_2-T_1)

       =3.7258\times 1\times 1.8\times (500-300)

       =3.7258\times 1.8\times (200)

       =1341.288 \ W/m

3 0
3 years ago
Write a program to control the operation of the RED/GREEN/BLUE LED (LED2) as follows: 1. If no button is pressed, the LED should
aalyn [17]

Answer:

See explaination

Explanation:

int RED=10; int BLUE=11; int GREEN=12; int BUTTON1=8; int BUTTON2=9; void setup() { pinMode(RED, OUTPUT); pinMode(BLUE, OUTPUT); pinMode(GREEN, OUTPUT); pinMode(BUTTON1, INPUT); pinMode(BUTTON2, OUTPUT); } void loop() { int BTN1_STATE=digitalRead(BUTTON1); int BTN2_STATE=digitalRead(BUTTON2); if(BTN1_STATE==HIGH) { digitalWrite(BLUE, HIGH); delay(1000); // Wait for 1 second digitalWrite(BLUE, LOW); } if(BTN2_STATE==HIGH) { digitalWrite(RED, HIGH); delay(4000); // Wait for 4 seconds digitalWrite(RED, LOW); } if(BTN1_STATE==HIGH && BTN2_STATE==HIGH) { digitalWrite(GREEN, HIGH); delay(2000); // Wait for 2 second digitalWrite(GREEN, LOW); } }

4 0
3 years ago
IM JI Suneou uo mm
Oksi-84 [34.3K]

Answer: g

Explanation:

5 0
3 years ago
I am trying to make a vacuum cannon but all I can use to get out the air is a speed pump to give air to bicycles. I need to make
Mrrafil [7]

We can actually deduce here that making a airtight seal will take different format. You can:

  • Use an epoxy-resin to create an airtight seal
  • Create a glass-metal airtight seal
  • Make a ceramic-metal airtight seal.

<h3>What is an airtight seal?</h3>

An airtight seal is actually known to be a seal or sealing that doesn't permit air or gas to pass through. Airtight seal are usually known as hermetic seal. They are usually applied to airtight glass containers but the advancement in technology has helped to broaden the materials.

We can see that epoxy-resin can used to create an airtight seal. They create airtight seals to copper, plastics, stainless steels, etc.

When making glass-metal airtight seal, the metal should compress round the solidified glass when it cools.

Learn more about airtight seal on brainly.com/question/14977167

#SPJ1

6 0
2 years ago
A step-down transformer (turns ratio = 1:7) is used with an electric train to reduce the voltage from the wall receptacle to a v
SOVA2 [1]

Answer:

wait lemme check it out

Explanation:

6 0
3 years ago
Other questions:
  • What is the main purpose of the alternator?
    13·1 answer
  • 3–102 One of the common procedures in fitness programs is to determine the fat-to-muscle ratio of the body. This is based on the
    5·1 answer
  • So in my settings i set it to send notifications too my email so ik when smtn happens but it doesn't even send stuff too it.....
    11·1 answer
  • The temperature of a gas stream is to be measured by a thermocouple whose junction can be approximated as a 1.2-mm-diameter sphe
    7·1 answer
  • Think about the science you have studied in the past or are currently studying. Give an example of something you have learned in
    11·1 answer
  • Use the method of cylindrical shells to find the volume generated by rotating the region bounded by the given curves about the y
    7·1 answer
  • Consider a sphere made of stainless steel with diameter of 25 cm. It is heated to temperature of 300°C for some chemical tests.
    12·1 answer
  • You talk with the owner and he likes the idea of using two large glulam beams as shown to carry the joist loads. Design the glul
    5·1 answer
  • Your friend has two substances A and B which are compressed liquid and superheated vapor respectively. Both are in rigid vessels
    15·1 answer
  • The static weight distribution is changed laterally by
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!