Algorihms
Sorting algorithms
Talk about sorting, why you need to sort things and what
criteria you sort by.
What is sort?
Ordering something that you can compare, it has more of something than another thing
Why sort?
To find fast
- page in a book
- which size of a bus school to use
- when is the next birthday, which two kids have adjacent birthdays
Find Max and Min
- most favorite and least favorite toys
What can you sort?
- numbers (print)
- redness (print)
- roundness (print)
- height - sticks
- thickness - books
- brightness (print pics - star, lamp, candle)
- activity - order (print)
- happiness-(print smileys)
What can you not sort?
- Apples and oranges (or can you?)
- laughter, pinecone, plus, dream
Sorting the same things differently
transport - bike, motorcycle, car, bus, boat, airplane - wheels, num people (print)
planets - sizes, how far from the sun (print)
words - size, alphabetically
Try sorting algorithms
kids. Every one will get a number and then they'll have to sort
themselves using different algorithms:
1. Selection sort. Find the biggest number, put it first, then find
the biggest among the numbers that are left, etc.
2. Bubble sort. Switch places with your partner to make sure the
smaller number is on the one side, the bigger number is on the other
3. Bucket sort. Allocate placeholders for the numbers (buckets) and
have kids run to the number that matches the numbers they are holding
4. Insertion sort. Sort 2, then 3, then 4, the last one inserts himself in the sorted list
5. Merge sort. split by groups, sort in a small group, then merge
Time the kids sorting and compare which algorithm works faster. Discuss the advantages of parallel processing (such as bubble sort - kids can swap in parallel)