← Back to course
Code Crew G3 / Week 07 / Crew Quest
6/6
Week 07 Β· Algorithms

Crew Quest

// Best way to solve it

Crew Quest: The Sort-Off

Raven sets up a Sort-Off. "Sort a small pile. Then mix it up and use a different plan," she says.

Rocket sorts his socks once. Then he tries a new way. "The second way was faster!" he says.

Nova hides a toy in a sorted line of eight things. "Try checking the middle first," she says. Let's help them run their own Sort-Off.

Find a small pile (10 books? 8 socks? 6 toys?). Time yourself sorting them.

Then RE-MIX and try a DIFFERENT algorithm.

What I sorted: ____________________________ (count: ____)
Run 1 algorithm: ___________________ Time: ____ sec
Run 2 algorithm: ___________________ Time: ____ sec
Faster algorithm: __________________ by ____ sec

Now try LINEAR vs BINARY search

Hide a small toy in a sorted line of 8 things. Can a friend find it

FASTER by checking the MIDDLE first (binary)?

Crew Brag Box
Show this to a grown-up. β˜… Earn a star if your second algorithm beat your first.

Week 7 Recap

  1. ALGORITHM = a step-by-step plan.
  2. Many algorithms can solve the same problem.
  3. SORT = put in order. SEARCH = find one item.
  4. Picking the right algorithm matters.
Try This Without Paper
1. Sort the silverware drawer by SIZE. Tell your method out loud.
2. Find a book on a shelf. What did your eyes do? (Linear or Binary?)
3. Race: alphabetize 8 toys with a sibling. Compare methods.
β—‡ HUMAN SORTING LINE
Each person writes a number from 1 to 20 on a paper card.
Line up in a row, in any order.
Use bubble it up: compare neighbors, and swap if the left number is bigger.
Keep going until nobody swaps. Count your swaps!
WEEK 7 REVIEW
  • Read the question.
  • Tap your answer.
What is an algorithm?
Which search needs a sorted list?
Bubble it up: the pair is 6 then 2. Do you swap?
Sort 5, 1, 4 from smallest to largest. What is the middle number?
StatementTrue or false?
Many algorithms can solve the same problem.?
Linear search looks at every item until it finds the one.?
Bubble it up stops when no swaps happen.?
An algorithm can never be improved.?
WHY THIS EXERCISEComparing and improving algorithms is a big part of computer science.

Coming up next…

Week 8: ABSTRACTION. Keeping the BIG idea, hiding small details.

← Friday