top of page
Image by Alexander Grey

Bubble & Merge Sort

Unit 3 Summary - part 5

Image by Nareeta Martin

There are Many Types of Sorting

Pay attention to the top left corner of this video

Image by Annie Spratt
Image by Kenrick Mills
Bubble Sort

Sorts from the left, one item at a time.

When it's done, it starts sorting from the left again, one item at a time.

  • Advantage: Simple and easy to code

  • Disadvantage: Slow to sort if there are many items in the list.

Image by Scott Webb
Image by Krystal Ng
Image by Adrian Infernus

If Bubble Sort were made into a folk dance,

it would look like this:
Image by J Lee

Merge Sort

Keeps on dividing the list into two, and then merge the parts together. 

  • Advantage: Very fast to sort if there are many items in the list.

  • Disadvantage: More complicated to code, so it takes up more storage space.

Image by Pawel Czerwinski
Image by Pawel Czerwinski
Image by Kseniya Lapteva

If Merge Sort were a folk dance,
it would be entertaining:

Image by Alexander Grey

BUBBLE SORT CODING

Image by Pawel Czerwinski

One Comparison

This coding will compare the first item with the second item only and then swap them:
Bubble Sort One Comparison.png
Image by Pawel Czerwinski

One Pass

This coding will compare items from left to right, and swap them, one time (one pass) only.
The highest/biggest number will be placed at the end of the list.
Bubble Sort One Pass.png
Candy Cotton

Keep Passing

This coding will compare items from left to right, and swap them, and will repeat until all numbers are fully sorted.
Bubble Sort Keep Passing.png
Image by Alexander Grey

Big O Notation

Image by Katie Rainbow 🏳️‍🌈
Image by Codioful (Formerly Gradienta)
Image by Codioful (Formerly Gradienta)
Image by Tamanna Rumee
Image by Alexander Grey

Oxford AQA IGCSE 2019

Candy Cotton

07.

Figure 5 shows a list of numbers that will be sorted from smallest to largest using the box bubble sort algorithm so that the smallest number will be at the left-hand end.

 

Figure 5

 

07.1.

Complete Table 1 to show the results of pass 2 and pass 3 of the bubble sort algorithm through the list from Figure 5.

 

The results of pass 1 and pass 4 have been completed for you. [2 marks]

 

Table 1

Bubble Sort1 AQA IGCSE 2019.png
Bubble Sort2 AQA IGCSE 2019.png
Image by Codioful (Formerly Gradienta)

07.2.

Why will the bubble sort algorithm complete another pass, even though the list is sorted after four passes? [1 mark]

__________________________________________________________________________________

Alternative answers:

  • To check that the list is fully sorted;

  • Six (list length -1) passes are needed to guarantee that the items are sorted

  • Because there needs to be a pass through the list when no swaps were made (in order to know that the list is sorted)

07.3.

For each statement tick one box to indicate if the statement is true or false. [2 marks]

Bubble Sort3 AQA IGCSE 2019.png

Answers:

  • False;

  • True

Image by Pawel Czerwinski
Visconsio Nekoland Logo.jpg
PT. Visconsio Kaya Jaya Masyhur

© 2020-2023 by Miana Kitty

bottom of page