Sorting Weights Using Algorithms

Overview

Students will sort a series of 8 identical containers from lightest to heaviest and write an algorithm explaining what they have done. An algorithm is a procedure or formula for solving a problem. Students will gain practice in writing an algorithm to achieve a simple task.

Rationale (Why we are doing this?)

Students will conduct a simple sorting activity to get a sense of how computers make decisions. They will then write instructions for how to complete the task using a flow chart or pseudo code.

Materials/Resources

  • Sand or water, 8 identical containers, a set of balance scales.
  • Copy of attached algorithm writing. Computers if www.draw.io is being used.

Context and Background Knowledge

Familiarity with how to use a balance.

Curricular Connections (Competencies and Content)

Create simple algorithms that reflect computational thinking
Explain their process, using appropriate terminology, and provide reasons for their selected solution and modifications
Reflect on their design thinking and processes
With support, plan appropriate investigations to answer their questions or solve problems they have identified
Observe, measure, and record data, using appropriate tools, including digital technologies
Suggest improvements to their investigation methods
Use tool or technology to explore and create patterns and relationships, and test conjectures

Grade 6 (ADST + Science + Math)

Explore + Understand + Create (Key elements/Lesson Design/Format)

  1. Fill each container with a different amount of sand or water. Seal tightly.
  2. Mix them up so that you no longer know the order of the weights.
  3. Find the lightest weight. What is the easiest way of doing this?

Note: You are only allowed to use the scales to find out how heavy each container is. Only two weights can be compared at a time.

  1. Choose 3 weights at random and sort them into order from lightest to heaviest using only the scales. How did you do this? What is the minimum number of comparisons you can make? Why?
  1. Now sort all of the objects into order from lightest to heaviest. When you think you have finished, check your ordering by re-weighing each pair of objects standing together.

Two Alternatives: 

Selection Sort

One method a computer might use is called selection sort. This is how selection sort works. First find the lightest weight in the set and put it to one side. Next, find the lightest of the weights that are left, and remove it. Repeat this until all the weights have been removed.

Count how many comparisons you made.

Quicksort

Quicksort is a lot faster than selection sort, particularly for larger lists. In fact, it is one of the best methods known. This is how quicksort works. Choose one of the objects at random, and place it on one side of the balance scales.

Now compare each of the remaining objects with it. Put those that are lighter on the left, the chosen object in the middle, and the heavier ones on the right. (By chance you may end up with many more objects on one side than on the other.)

Choose one of the groups and repeat this procedure. Do the same for the other group. Remember to keep the one you know in the center. Keep repeating this procedure on the remaining groups until no group has more than one object in it. Once all the groups have been divided down to single objects, the objects will be in order from lightest to heaviest.

To demonstrate their learning have students write an algorithm using a flow chart or pseudo code explaining how they solved the sorting problem.  Online applications such as www.draw.io maybe useful, but this can also be done with ruler and a pencil.

Creating Algorithms to Solve Problems – Click to Download PDF