
5.4. Sorting Algorithms¶
This lesson introduces sorting algorithms, a frequently used algorithm in programming for processing data sets. It is also an introduction to the relative efficiencies of different algorithms that solve the same problem.
CSP Framework | |||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||||||||||||||||||||||||||||||||
Enduring Understanding AAP-2: The way statements are sequenced and combined in a program determines the computed result. Programs incorporate iteration and selection constructs to represent repetition and make decisions to handle varied input values. | |||||||||||||||||||||||||||||||||||||||||
Learning Objective AAP-2.A: Express an algorithm that uses sequencing without using a programming language. | |||||||||||||||||||||||||||||||||||||||||
Learning Objective AAP-2.G: Express an algorithm that uses selection without using a programming language. | |||||||||||||||||||||||||||||||||||||||||
Learning Objective AAP-2.J: Express an algorithm that uses iteration without using a programming language. | |||||||||||||||||||||||||||||||||||||||||
Professional Development
The Student Lesson: Complete the activities for Complete the activities for Mobile CSP Unit 5 Lesson 5.4: Sorting Algorithms.
Materials
- Decks of cards - can use 13 cards of one suit per student group, although one deck would be ideal.
- Alternatives: https://deck.of.cards/ or PlayingCards.io virtual playing cards (scroll down and select 'Other')
- Projection system
- Videos
5.4.1. Learning Activities¶
Estimated Length: 45 minutes
- Hook/Motivation (5 minutes):
- Sorting "Contest": Students should form groups of 2-4. Ask the students to discuss in their groups the fastest way to sort a deck of cards. Then distribute one deck of cards to each group (or one suit from a deck), leaving them face down. Start a timer and see which group can get their deck sorted the fastest. Once all the groups have completed, have each group share their strategy for sorting. Emphasize the point that there are different algorithms to solve the same problem, but that each has a different efficiency.(It might be helpful to have the students describe their sort in the form of a pseudocode algorithm -- i.e., step by step.)
- Alternative Hook: Ask the students to sort themselves by their birthday (month and day). Have them make a line in class. Once completed, ask them to talk about strategies they used to sort themselves. It might be helpful here to ask the students whether their algorithm required them to compare their birthdays with each other (bubble sort, merge sort) or whether they could do it without comparisons (bucket sort).
- Experiences and Exploration (30 minutes):
- Bubble Sort (10 minutes): Play the video demonstrating the bubble sort and ask the students to hypothesize about how it's being solved. After the video, review the interactive question and the pseudocode for the bubble sort.
- Merge Sort (10 minutes): Play the video demonstrating the merge sort and ask the students to hypothesize about how it's being solved. After the video, review the interactive question and the pseudocode for the merge sort.
- Bucket and Merge Sort (10 minutes): Play the video demonstrating the bucket and radix sort and ask the students to hypothesize about how it's being solved. After the video, review the interactive question and the pseudocode for the bucket and radix sort.
- Rethink, Reflect, and Revise (10 minutes):
- Practice: Have the students practice each sort in their groups with the deck of cards
- Note: Bucket Sort Exercise: Sort By Rank and Suit - Suppose you wanted to sort the deck of cards by both rank and suit, so that all the clubs come before all the diamonds come before all the hearts come before all the spades. How would you do this?
Answer: Once the deck has been sorted by rank. You could sort it into suit using 4 buckets, one for each suit. Try it! - Wrap-Up: Have the students complete the interactive exercises and portfolio reflections for the lesson
5.4.2. Professional Development Reflection¶
Discuss the following questions with other teachers in your professional development program.
-
I am confident I can teach this lesson to my students.
- 1. Strongly Agree
- 2. Agree
- 3. Neutral
- 4. Disagree
- 5. Strongly Disagree
Before you keep reading...
Making great stuff takes time and $$. If you appreciate the book you are reading now and want to keep quality materials free for other students please consider a donation to Runestone Academy. We ask that you consider a $10 donation, but if you can give more thats great, if $10 is too much for your budget we would be happy with whatever you can afford as a show of support.