Topic 3 Sorting algorithms
Task 1 Bubble sort
Use the girls’ names cards.
Place the cards in the sequence of numbers 1, 2, 3… 10
Perform a manual Bubble Sort to get the cards in alphabetical order.
1.
What are the last 2 names after the first pass? Amelia and Sophie
What are the first two names after the second pass? Jessica and Isabella
What are the third and fourth names after the third pass? Isabella and Isla
What are the seventh and eighth names after the fourth pass? Lily and Olivia
What are the fourth and fifth names after the fifth pass?
What are the first two names after the sixth pass?
Which names are out of sequence after the seventh pass?
Are any names out of sequence after the eighth pass?
How many passes were needed to sort the cards?
2. Use what you have done with the name cards to write an algorithm to perform the steps
in a bubble sort
1
3. Task 2: Insertion sort
1.
Lay out the girls’ names cards in the sequence of numbers 1, 2, 3… 10
On the first pass, Sophie is examined. The card is already in the correct place, so now you
have
Lily, Sophie, Jessica
On the second pass, put Jessica into the correct position.
On the third pass, what is the next name to be placed in the correct position?
After the fourth pass, what are the first 5 names in the list?
After the sixth pass, what is the first name in the list?
Which name is sorted on the 7th pass?
How many passes are needed to sort the 10 names?
2. Use what you have done with the name cards to write an algorithm to perform the steps
in a Insertion sort
2
Task 3: Merge sort
1. Use the first girls’ name cards. Lay them in a row in numerical sequence.
Split the cards into two sublists.
What is your first sublist? Sophie,Lily,Jessica,Ava
Split the lists into pairs.
What is your 3rd pair? Ava,Poppy
Split the pairs into single items.
Now merge each pair separately
Are they all in sequence?
No
Merge the first two pairs into sorted groups of four. What are the names in the first sorted
group?
Sophie,Lily,Jessica,Isabella
Finally merge the two groups of four into the “output” list (placed below your two groups
of 4). Which is the third card in the sorted list? Jessica
3
2.Use what you have done with the name cards to write an algorithm to perform the steps in a
merge sort