Coding sorting algorithms

In this lesson, learners will analyse and evaluate code for bubble sort and insertion sort in Python, as well as comparing different implementations of the bubble sort algorithm.

This quiz includes images that don't have any alt text - please contact your teacher who should be able to help you with an audio description.

Quiz:

Intro quiz - Recap from previous lesson

Before we start this lesson, let’s see what you can remember from this topic. Here’s a quick quiz!

Question 1

Question 2

Question 3

Question 4

Question 5

Question 6

Question 7

Q1."The insertion sort algorithm works by grouping the items in a list into two parts: a sorted sublist and an unsorted sublist."

1/7

Q2."With each pass through the list, an item from the unsorted sublist is compared to items in the sorted sublist until it is inserted into the correct position."

2/7

Q3."If the item at the current position is greater than value, copy it into the next item and move on to the previous item in the list"

3/7

Q4."Insertion sort compares an item from the unsorted sublist with the items in the sorted sublist and places it in the correct position."

4/7

Q5."Insertion sort is usually slower to execute than bubble sort on large, unordered data sets."

5/7

Q6."Insertion sort is usually slower to execute than bubble sort on large, unordered data sets."

6/7

Q7."During a pass of an insertion sort, elements in the sorted part of the list are copied into the next position, to make space for the value to be inserted."

7/7

This quiz includes images that don't have any alt text - please contact your teacher who should be able to help you with an audio description.

Quiz:

Intro quiz - Recap from previous lesson

Before we start this lesson, let’s see what you can remember from this topic. Here’s a quick quiz!

Question 1

Question 2

Question 3

Question 4

Question 5

Question 6

Question 7

Q1."The insertion sort algorithm works by grouping the items in a list into two parts: a sorted sublist and an unsorted sublist."

1/7

Q2."With each pass through the list, an item from the unsorted sublist is compared to items in the sorted sublist until it is inserted into the correct position."

2/7

Q3."If the item at the current position is greater than value, copy it into the next item and move on to the previous item in the list"

3/7

Q4."Insertion sort compares an item from the unsorted sublist with the items in the sorted sublist and places it in the correct position."

4/7

Q5."Insertion sort is usually slower to execute than bubble sort on large, unordered data sets."

5/7

Q6."Insertion sort is usually slower to execute than bubble sort on large, unordered data sets."

6/7

Q7."During a pass of an insertion sort, elements in the sorted part of the list are copied into the next position, to make space for the value to be inserted."

7/7

Video

Click on the play button to start the video. If your teacher asks you to pause the video and look at the worksheet you should:

  • Click "Close Video"
  • Click "Next" to view the activity

Your video will re-appear on the next page, and will stay paused in the right place.

Worksheet

These slides will take you through some tasks for the lesson. If you need to re-play the video, click the ‘Resume Video’ icon. If you are asked to add answers to the slides, first download or print out the worksheet. Once you have finished all the tasks, click ‘Next’ below.

This quiz includes images that don't have any alt text - please contact your teacher who should be able to help you with an audio description.

Quiz:

Coding Sorting Algorithms

This quiz is to assess your learning from this lesson. Read the description below and select which term it is referring to:

Question 1

Question 2

Question 3

Question 4

Question 5

Question 6

Question 7

Question 8

Question 9

Q1.'A more efficient version of bubble sort uses a variable to flag when a swap was made during a single pass'

1/9

Q2.'The insertion sort algorithm copies the value to be inserted in a variable at the end of each pass'

2/9

Q3.'During a pass of an insertion sort, elements in the sorted part of the list are copied into the next position, to make space for the value to be inserted'

3/9

Q4.Two improvements to the bubble sort algorithm are reducing the number of comparisons after each pass, and stopping once no swaps are made during a single pass.

4/9

Q5."Bubble sort compares items next to each other in the list and swaps them if they are in the wrong order."

5/9

Q6."Insertion sort compares an item from the unsorted sublist with the items in the sorted sublist and places it in the correct position."

6/9

Q7."Bubble sort is good at sorting large collections of unordered data."

7/9

Q8."Bubble sort can be really fast at sorting data that is nearly in order."

8/9

Q9."Insertion sort is usually slower to execute than bubble sort on large, unordered data sets."

9/9

This quiz includes images that don't have any alt text - please contact your teacher who should be able to help you with an audio description.

Quiz:

Coding Sorting Algorithms

This quiz is to assess your learning from this lesson. Read the description below and select which term it is referring to:

Question 1

Question 2

Question 3

Question 4

Question 5

Question 6

Question 7

Question 8

Question 9

Q1.'A more efficient version of bubble sort uses a variable to flag when a swap was made during a single pass'

1/9

Q2.'The insertion sort algorithm copies the value to be inserted in a variable at the end of each pass'

2/9

Q3.'During a pass of an insertion sort, elements in the sorted part of the list are copied into the next position, to make space for the value to be inserted'

3/9

Q4.Two improvements to the bubble sort algorithm are reducing the number of comparisons after each pass, and stopping once no swaps are made during a single pass.

4/9

Q5."Bubble sort compares items next to each other in the list and swaps them if they are in the wrong order."

5/9

Q6."Insertion sort compares an item from the unsorted sublist with the items in the sorted sublist and places it in the correct position."

6/9

Q7."Bubble sort is good at sorting large collections of unordered data."

7/9

Q8."Bubble sort can be really fast at sorting data that is nearly in order."

8/9

Q9."Insertion sort is usually slower to execute than bubble sort on large, unordered data sets."

9/9

Lesson summary: Coding sorting algorithms

It looks like you have not completed one of the quizzes.

To share your results with your teacher please complete one of the quizzes.

Time to move!

Did you know that exercise helps your concentration and ability to learn?

For 5 mins...

Move around:
Climb stairs

On the spot:
Dance

Take part in The Big Ask.

The Children's Commissioner for England wants to know what matters to young people.

Share your views and have your voice heard.

The next lesson in Algorithms is "Merge sort"

Browse Oak's lessons: