Photo AI

Fill in the blank arrays to show the steps involved in applying the bubble sort algorithm to the array [ 3, 5, 1, 4, 2 ] - AQA - GCSE Computer Science - Question 11 - 2021 - Paper 1

Question icon

Question 11

Fill-in-the-blank-arrays-to-show-the-steps-involved-in-applying-the-bubble-sort-algorithm-to-the-array-[-3,-5,-1,-4,-2-]-AQA-GCSE Computer Science-Question 11-2021-Paper 1.png

Fill in the blank arrays to show the steps involved in applying the bubble sort algorithm to the array [ 3, 5, 1, 4, 2 ]. You only need to show the missing steps whe... show full transcript

Worked Solution & Example Answer:Fill in the blank arrays to show the steps involved in applying the bubble sort algorithm to the array [ 3, 5, 1, 4, 2 ] - AQA - GCSE Computer Science - Question 11 - 2021 - Paper 1

Step 1

First Step Change

96%

114 rated

Answer

The first comparison is between 3 and 5. No change occurs, so the array remains: [3, 5, 1, 4, 2]

Step 2

Second Step Change

99%

104 rated

Answer

Next, we compare 5 and 1. Since 5 > 1, we swap them: [3, 1, 5, 4, 2]

Step 3

Third Step Change

96%

101 rated

Answer

Now we compare 5 and 4. Since 5 > 4, we swap: [3, 1, 4, 5, 2]

Step 4

Fourth Step Change

98%

120 rated

Answer

Next, we compare 5 and 2. Since 5 > 2, we swap: [3, 1, 4, 2, 5]

Step 5

Fifth Step Change

97%

117 rated

Answer

The first iteration completes with the largest element at the end. The next pass starts, comparing 3 and 1. Since 3 > 1, we swap: [1, 3, 4, 2, 5]

Step 6

Sixth Step Change

97%

121 rated

Answer

Next, we compare 3 and 4. No change occurs: [1, 3, 4, 2, 5]

Step 7

Seventh Step Change

96%

114 rated

Answer

Next, we compare 4 and 2. Since 4 > 2, we swap: [1, 3, 2, 4, 5]

Step 8

Eighth Step Change

99%

104 rated

Answer

Completion of the second iteration moves to the next pass, starting with 1 and 3: [1, 2, 3, 4, 5]

Step 9

Final State

96%

101 rated

Answer

The sorted array reaches: [1, 2, 3, 4, 5]

Join the GCSE students using SimpleStudy...

97% of Students

Report Improved Results

98% of Students

Recommend to friends

100,000+

Students Supported

1 Million+

Questions answered

;