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
Consider a system with two tasks, Task1 and Task2. Task1 has a period of 200 ms, and Task2 has a period of 300 ms. All tasks ini
Murrr4er [49]

<u>Explanation:</u>

Task 1 time period = 200ms, Task 2 time period = 300ms

Task ticked = \frac{1000ms}{200ms}= 5  →  5 times

Task 2 ticked =\frac{1000ms}{300ms} = 3.33 → 3 times

At 600 ms → 200ms 200ms 200ms

                     300ms → \frac{30ms}{60ms}

Largest time period = H.C.M of (200ms, 300ms)

                                 = 600ms

4 0
2 years ago
Write a statement that calls the recursive method backwardsAlphabet() with parameter startingLetter.
Tcecarenko [31]

Recursion refers to the act of calling a function itself. With the use of this strategy, complex problems can be reduced to more manageable, simpler ones. Recursion might be a little challenging to comprehend. The best method to figure out how it works is to experiment with it.

<h3>How to write a programme by recursive method ?</h3>

The process of making a function call itself is known as recursion. With the use of this strategy, complex problems can be reduced to more manageable, simpler ones. Recursion might be a little challenging to comprehend. Experimenting with it is the most effective way to learn how it functions.

public class Recursive Calls {

public static void backwards Alphabet(char currLetter) {

if (currLetter == 'a') {

System.out.println(currLetter);

}

else {

System.out.print(currLetter + " ");

backwards Alphabet(--currLetter);

}

return;

}

public static void main (String [] args) {

char starting Letter = '-';

starting Letter = 'z';

// Your solution goes here

backwards Alphabet(starting Letter);

return;

}

}

To learn more about recursive method refer to :

brainly.com/question/24167967

#SPJ4

6 0
1 year ago
1. True/False The Pressure Relief valve maintains the minimum pressure in the hydraulic circuit​
elena55 [62]
Yeah it’s true. Good luck!!
3 0
3 years ago
Multiply. Write the answer in simplest form. 1 3/10×1/8
kicyunya [14]

9514 1404 393

Answer:

  13/80

Explanation:

The product is ...

  (1 3/10)×(1/8) = (13/10)×(1/8) = (13×1)/(10×8) = 13/80

4 0
2 years ago
A gear train has two gears. The driver gear has 8 teeth and a diametral pitch of 6 teeth/inch. the follower gear has 24 teeth. W
Sliva [168]

Answer:

18 teeth/inch

Explanation:

Given that: i. driver gear has 8 teeth and diametral pitch of 6 teeth/inch.

                  ii. follower gear has 24 teeth.

Let the followers diametral pitch be represented by x.

Then,

8 teeth ⇒  6 teeth/inch

24 teeth ⇒ x teeth/inch

So that;

x = \frac{24 x 6}{8}

   = \frac{144}{8}

   = 18 teeth/inch

The diametral is 18 teeth/inch

3 0
2 years ago
Other questions:
  • According to the zeroth law of thermodynamics, which of the following cannot occur?
    7·1 answer
  • There is a proposal in Brooklyn to construct a new mid-rise apartment building on a vacant lot at the intersection of Avenue A a
    8·1 answer
  • (10 points) A single crystal in the titanium cable is oriented so that the [001] direction is parallel to the applied load. If t
    14·1 answer
  • Suppose you are implementing a relational employee database, where the database is a list of tuples formed by the names, the pho
    14·1 answer
  • A turboprop engine consists of a diffuser, compressor, combustor, turbine, and nozzle. The turbine drives a propeller as well as
    12·1 answer
  • This is a multi-part question. Once an answer is submitted, you will be unable to return to this part As steam is slowly injecte
    15·1 answer
  • A mechanical system comprises three subsystems in series with reliabilities of 98, 96, and 94 percent. What is the overall relia
    10·1 answer
  • How long does it take electrons to get from a car battery to the starting motor? Assume the current is 300 A and the electrons t
    10·1 answer
  • Determine the number of flipflops required to build a binary counter that count from 0 to 2043
    14·1 answer
  • 1. What's the maximum overall length of the part?<br> 2. What material is used to fabricate the part
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!