2. Agenda
● 2.4 Do Now
● Unit 2 Tracker
● Unit 2 Test/Study Guide
● 2.4 Lecture
○ SWBAT use various sorting algorithms to sort data
● 2.4 Activity
○ With a partner
● 2.4 Exit Ticket
○ 15 minutes timed
● Finish Early?
○ Revises from Unit 1/Unit 2 Tracker
○ Typing Homework
○ Unit 2 Extra Credit Opportunities
4. Do Now
Sort the following numbers from lowest to highest. Then
answer, the two questions.
15 6 8 34 5 26 17 18 41 22
1. What was your strategy in sorting?
5. DISCUSSION
a) Think of a time when you were using a computer
application or website that sorted values for you.
b) Think about how you sorted the numbers in the Do Now.
Would you use the same method to sort a set of 5000
numbers?
i) What might you change?
ii) What if you had a buddy to help you sort?
6. ALGORITHMS
● An algorithm is a specific process or set of rules followed to get to a
solution.
Examples:
● Recipes
● handshake problem
● Directions
● fencepost problem
● -n-1
7. SORTING ALGORITHMS
● Algorithms computers use to help it sort data
● Computer can only compare two items at a time
● We are going to learn TWO sorting algorithms.
○ SELECTION SORT
○ INSERTION SORT
8. SELECTION SORT
Sort a set of data by continuously “selecting”
the next lowest value from the unsorted list and
adding it to the sorted list (new set)
9. SELECTI
ON SORT
Algorithm:
1. Take the first item. Compare it to the
second item. The lower one is your
current minimum.
2. Continue to compare current min with the
rest of the values, always keeping the
lower number.
3. Once minimum is found, move to new
set.
4. Repeat.
EACH TURN, IT IS FINDING
THE LOWEST NUMBER
AND THEN MOVING IT TO THE
LEFT
(SORTED LIST)
11. INSERTION SORT
Takes an unsorted set of
values and sorts it in a
new set by “inserting” one
value at a time.
12. INSERTION
SORT
Algorithm:
1. Take the first card in the unsorted set and put it in
the back of the new sorted set.
2. If it’s lower than the one before it, put it in front. If it is
higher, put it behind.
3. Repeat step 2 until the card is in its proper place.
4. Repeat steps 1-3 until all cards are sorted.
Each new value is “inserted” into the
correct spot in the order, one at a time.
14. EXTRA CREDIT
Receive up to 20 extra credit points by:
1. Creating 2 videos, 1 for selection sort
and 1 for insertion sort.
2. You are verbally explaining the
difference as you show the difference,
similar to the provided example but
with a verbal explanation.
3. Be creative and use whatever
supplies you have around your house
to sort. Playing cards, paper, jersey
numbers, etc.
15. Agenda
● 2.4 Do Now
● Unit 2 Tracker
● Unit 2 Test/Study Guide
● 2.4 Lecture
○ SWBAT use various sorting algorithms to sort data
● 2.4 Activity
○ With a partner
● 2.4 Exit Ticket
○ 15 minutes timed
● Finish Early?
○ Revises from Unit 1/Unit 2 Tracker
○ Typing Homework
○ Unit 2 Extra Credit Opportunities