What Are Sorting Algorithms?


This sorting algorithm lesson is instrumental in fostering AI literacy among students, providing a foundational understanding of how algorithms operate. Algorithms are a core component of AI, used to organize and process information. By grasping these sorting mechanisms, students gain insights into the inner workings of online platforms, enhancing their comprehension of how content is personalized online. This knowledge empowers them to navigate the digital world more effectively and critically, recognizing the impact of algorithms on their daily online interactions. Moreover, fostering an early understanding of these concepts prepares students for a future increasingly shaped by AI and data-driven technologies, making them more informed and responsible digital citizens.
Materials Needed Time needed 
  • Small slips of paper
  • Writing utensils
Approximately 30-45  minutes
  • Students will be able to explain the basic principles of sorting algorithms and differentiate between their processes.
  • Students will be able to analyze the efficiency and practical applications of different sorting algorithms in real-world scenarios, such as social media and online shopping.
  • Students will be able to collaborate effectively to achieve a common goal, demonstrating teamwork and communication skills during the sorting simulation activity.
Key Concepts & Vocabulary 

Algorithm: A set of step-by-step instructions for solving a problem or completing a task.

Bubble Sort: A simple sorting algorithm that repeatedly steps through the list, swapping adjacent elements if they are in the wrong order.

Quick Sort: An efficient sorting algorithm that divides the data into smaller parts, sorts them, and then combines them.

Pivot (in Quick Sort): A central value used to divide data into subsets during the Quick Sort process.

Efficiency: The degree to which an algorithm effectively uses computing resources like time and memory.

  • Describe the purpose of the lesson: “Sorting algorithms are like the methods used to organize things neatly. Imagine you have a big pile of books and you want to arrange them in a certain order, like alphabetically. Sorting algorithms do something similar, but with data on computers. They’re extremely important because they help find information quickly (like searching for a book title in a well-organized library), make data easier to understand and use (like arranging files in order), and help computers perform tasks efficiently (like scheduling appointments in a calendar). Basically, they’re the behind-the-scenes helpers that keep our digital world organized and running smoothly.”
  • Human Sorting Algorithm Simulation: Have students write a two-digit number on a small piece of paper. (i.e., between 10 and 99.) Students should not share their numbers with each other yet. Put students randomly into a line. (Without any attention to order.) 
  • Lead them in sorting themselves using Bubble Sort and then Quick Sort methods. It would be most effective to have them write a new number before starting the second method. (See end of plan for illustrations of both sorting methods.)
    • Bubble Sort Method: Students compare their numbers with the people to their immediate right or left. The higher number goes one way and the lower number goes the other way. Eventually, they will create a sequence in numerical order.
    • Quick Sort Method: Pick a student who is standing somewhere in the middle of the room. That student says out loud the number on his/her paper. (That person is the first “pivot.”) Everyone whose number is higher goes to one side, and everyone whose number is smaller goes to the other side. At this point, order on each side doesn’t matter. Now pick someone halfway between the first pivot  and one end.That person becomes the second “pivot.” Students on that side pivot larger and smaller. Keep doing it within the remaining gaps, until the number line is sorted.
  • Recap the simulation with a conclusion explaining how this illustrates algorithms online: “As we’ve seen through our sorting activities today, algorithms like Bubble Sort and Quick Sort play a crucial role in organizing and managing data in the digital world. In social media, algorithms sort through vast amounts of content, like posts and videos, to show you what’s most relevant based on your interests, similar to how we sorted numbers based on their value. Online shopping websites use similar sorting methods to recommend products. They analyze your browsing and purchase history, then prioritize items you’re more likely to buy, just as we sorted ourselves into a numerical sequence. So, every time you scroll through your social media feed or shop online, remember that behind the scenes, algorithms are working hard to sort and present the most relevant information to you, making your digital experience both efficient and personalized.”
Discussion Questions
  • How did the Bubble Sort and Quick Sort methods differ in the way they sorted the numbers? Which steps did you find easier or more challenging in each method?
  • What challenges did you face in communicating and coordinating with each other?
  • Can you think of a real-life (or online) situation where a sorting method like Bubble Sort or Quick Sort could be useful?What did this activity teach you about how computers use algorithms to solve problems?
  • How do you think understanding sorting algorithms can be helpful in other areas of learning or in everyday digital activities?
Supplemental Activity Ideas 

Algorithm Efficiency Debate: Organize a debate where students argue the merits and drawbacks of different sorting algorithms in various scenarios. This idea fosters critical thinking and a deeper understanding of algorithm efficiency and applicability.

Algorithm Design Challenge: There are many other sorting algorithms besides the two mentioned in this lesson. Have students attempt to create their own algorithms for the number sorting done earlier in this lesson. Try them out and see if they are faster than the Bubble or Quick Sort methods.

Algorithms for Other Sorting Situations: Have students create their own algorithms for sorting everyday objects (such as books or playing cards), and then explain their processes and efficiency to the class. This activity encourages creative thinking and a deeper understanding of algorithmic principles.

Sources to Learn More