Mod 3 Lesson 2 Me First! Sorting Please get out a piece of paper for notes. Include your name, Date Sorting Algorithms You will turn these in later. Intro to Programming Mod 3 Lesson 2 Me First! Sorting
Learning Objectives Students will be introduced to the idea of sorting data in order. Students will be able to sort information using several algorithms.
Getting Started Activity There is no talking in this activity!!!! I will break you into groups and you will need to put yourselves in order, based on the month in which you were born. Remember, no talking!!
After the Activity Check the groups How many comparisons did you make Now, again without talking, organize the entire class by day of the month in which you were born. What was the effect of trying to organize the entire group? Can you suggest a more efficient method?
How do you put things in order? Watch the first Sorting Video Two items Three items Four Ten 52 100 10000000000000000000000000000000
How did the first video sort the items? On your notes, give a summary of the Bubble sort as well as the sample below. Bubble Sort Slow Works by checking two values, if they are out of order, switch them (Check-Switch) Your turn: Sort the following from low to high showing each pass. Low High 30 15 8 12 20 9 1
Are there any other ways to sort? Let’s look at another method of sorting The selection sort. Watch the video How does it work?
Selection Sort How fast is it? How it works Check for the smallest On your notes, give a summary of the Selection sort as well as the sample below. How fast is it? How it works Check for the smallest Switch. It is counted as a pass every time there is a switch. (Check, Mark, Switch) More efficient than the Bubble Sort. Your turn Sort the following, showing each pass. Low High 30 15 8 12 20 9 1
Quick Sort Watch the video Can you describe how this sort works? On your notes, give a summary of the Quick sort as well as the sample below. Watch the video Can you describe how this sort works? Pick a card Put the cards smaller to the left, the cards larger to the right Pick up the pile to the left and repeat Pick up the pile to the right and repeat The most efficient of the three A ‘Divide and Conquer’ sort
Summary Mark a section on the bottom of your paper “Summary:” Summarize today’s ideas Bubble, Selection and Insertion Sorts How to they work? Which do you like best and why? When finished turn it into the Macintosh