T5 Worksheet 5
T5 Worksheet 5
1. What are the last two names after the first pass?
Charlie, Oscar
2. What are the first two names after the second pass?
George, Harry
3. What are the third and fourth names after the third pass?
Jack, Arthur
4. What are the seventh and eighth names after the fourth pass?
Muhammad, Noah
5. What are the fourth and fifth names after the fifth pass?
Jack, Charlie
1
Worksheet 5 Sorting algorithms
Unit 1 Fundamentals of algorithms
6. What are the first two names after the sixth pass?
Arthur, George
2
Worksheet 5 Sorting algorithms
Unit 1 Fundamentals of algorithms
4. Now merge the four pairs into two groups of four. What are the names in the first sorted
group?
George, Harry, Noah, Oliver
5. Now merge the two groups together. What is the third card in the list?
Harry
3
Worksheet 5 Sorting algorithms
Unit 1 Fundamentals of algorithms
Task 4: Algorithms
You have studied three algorithms for sorting.
Look at the following algorithm written in pseudo-code for one type of sorting algorithm.
4
Worksheet 5 Sorting algorithms
Unit 1 Fundamentals of algorithms
1. There is a for loop at the end of the algorithm (lines 13-15) which contains the
pseudo-code:
OUTPUT names[i]
What do you think this does?
It displays each item in order.
2. At the start of the program, the array called names is initialised with six names.
What will the value be that is stored in numItems?
5
3. Look at lines 5 to 9 in the code and explain what they are doing.
It is ordering each name alphabetically into temp and then putting it before names[item+1].