Skip to content
6 min read

How to Teach Algorithms and Computational Thinking in Middle School (Grades 6–9): Lesson Ideas, Activities & Worksheets

A practical guide to teaching algorithms and computational thinking in Grades 6–9: unplugged lessons, pseudocode tasks, differentiation, misconceptions and assessment.

Why teach algorithms and computational thinking in Grades 6–9?

Quick answer: Teach algorithms and computational thinking by starting with everyday step-by-step tasks students already know, moving to unplugged sorting and searching activities, then formalizing the ideas as pseudocode and flowcharts before any coding. This sequence builds decomposition, pattern recognition, abstraction and algorithm design without overwhelming beginners.

Computational thinking is the problem-solving foundation under every coding lesson. In middle school it matters because students are ready for abstract reasoning but still benefit from concrete, hands-on models. The four pillars — decomposition (breaking a problem apart), pattern recognition (spotting what repeats), abstraction (ignoring irrelevant detail), and algorithm design (writing clear steps) — give you a shared vocabulary you can reuse all year.

Our Algorithms and Computational Thinking unit for Grades 6–9 packages this progression into ready-to-teach worksheets, projects and slides so you can focus on facilitating rather than building resources from scratch.

What is a good lesson sequence?

A reliable four-lesson arc works well:

  1. Everyday algorithms. Students write precise instructions for making a sandwich or brushing teeth, then a partner follows them literally. The comedy of a mis-followed step teaches precision instantly.
  2. Searching. Play “guess the number 1–100.” Compare guessing one-by-one (linear search) with always halving the range (binary search). Count the guesses to reveal efficiency.
  3. Sorting. Give groups shuffled number cards and have them invent a sorting method, then compare with bubble sort and selection sort.
  4. Formalizing. Rewrite one activity as pseudocode and a flowchart.

Here is simple pseudocode students can produce by lesson four:

SET low = 1, high = 100
REPEAT
  guess = (low + high) / 2
  IF guess too high THEN high = guess - 1
  ELSE IF guess too low THEN low = guess + 1
UNTIL guess is correct

Which unplugged activities work best?

Unplugged tasks remove the friction of syntax and keep the focus on thinking:

  • Human robot: one student is the “robot” who only obeys commands like FORWARD, TURN LEFT, PICK UP. Classmates debug the instructions to navigate a taped grid.
  • Card sorting relay: race two groups using different sort strategies and discuss why one finished first.
  • Flowchart a morning routine: introduces decisions (IF it is raining) and loops (UNTIL the bus arrives).

These pair naturally with programming once students are ready. When you move to code, our Programming with Python unit for Grades 6–9 lets students turn their pseudocode into working programs, and the Data and Encoding: Binary & Digital Images unit shows how algorithms operate on the data underneath.

How do I differentiate across Grades 6–9?

Keep the task, change the depth:

  • Grade 6: focus on writing clear, ordered steps and following them exactly. Success = a partner can complete the task without asking questions.
  • Grade 7–8: add decisions and loops, and ask students to count steps to compare two algorithms.
  • Grade 9: introduce Big-O intuition informally (“does the work double or grow slowly when the input doubles?”) and have students justify which algorithm they would choose and why.

Offer worked examples for students who need support and “improve this algorithm” extension prompts for those who race ahead.

Common misconceptions and how to assess

Watch for these misconceptions: believing computers “know what you mean” (they follow steps literally); thinking there is only one correct algorithm (efficiency and trade-offs matter); and confusing a faster computer with a faster algorithm. Address each by having students test their steps on a peer who follows them exactly.

For assessment, use a short rubric scoring correctness (does it produce the right result?), precision (are steps unambiguous?), and efficiency (are there redundant steps?). A one-page exit ticket asking students to write and trace an algorithm gives quick evidence of understanding.

What projects extend the learning?

Once the four-lesson arc is done, students need something that produces an artifact they can hand in and defend. These three work well as a capstone, and all of them start as a flowchart on paper:

  1. Recipe app flowchart. Students design a flowchart that walks a user through a recipe, and it has to include at least one decision (IF the pan is hot) and one loop (UNTIL cooked). The cooking context keeps the edge cases obvious.
  2. Board-game bot. Students write the algorithm a simple bot would follow to win at tic-tac-toe, expressed as ordered IF rules. Order is the whole lesson here: put “take the win” below “block the opponent” and the bot loses games it should have won.
  3. Sorting showdown. Students run two sorting methods on the same deck of cards and record how many comparisons each one needs. Doubling the deck size and repeating the count is what turns efficiency from a word into a number.

Grade these on the same three criteria you used earlier, and require every project to be traced by a classmate before it is submitted. A partner who cannot follow the steps has found a precision problem the author could not see.

If you can spare one more period, run a gallery trace. Projects go out on desks, students rotate every four minutes, and each visitor runs the algorithm with one input the author did not plan for. It produces better feedback than a written peer review because the failures happen in front of both of them.

What can I run in a single 45-minute period?

If you have one period and no prep time, run this: five minutes to introduce an algorithm as “precise steps,” fifteen minutes on the card sorting relay, fifteen minutes turning one group's method into pseudocode, and ten minutes comparing step counts across the room. Every student leaves with a written algorithm and vocabulary you can point back to for the rest of the year.

If the period is shorter, swap the relay for “loop the dance”: groups choreograph a short routine, write it out move by move, then rewrite it using REPEAT 4 TIMES. Students see repetition compress in front of them, and it takes about ten minutes end to end.

FAQ

What age should students start learning algorithms?

Students can begin thinking algorithmically well before middle school, but Grades 6–9 are ideal for formalizing the ideas with pseudocode and flowcharts because students can now handle abstraction and multi-step reasoning.

Do I need to know how to code to teach this?

No. Most computational-thinking lessons are unplugged and require no programming background. You can teach decomposition, searching and sorting entirely with paper, cards and classroom movement.

How long does an algorithms unit take?

A focused introduction takes about four to six lessons. Add project work and a coding bridge and it comfortably fills three to four weeks of class time.

Bring it into your classroom

Ready to teach this without building everything yourself? The Algorithms and Computational Thinking unit for Grades 6–9 gives you worksheets, projects and slides aligned to the progression above — download it and run your first lesson this week.

Want a ready-to-teach curriculum?Complete, ready-to-use teaching curricula for Middle & High School — structured units, assessments, and more.

All Middle School Curricula →

Teaching High School classes?Complete, ready-to-use teaching curricula for Middle & High School — structured units, assessments, and more.

All High School Curricula →
✏
About the author
The TeachLessons Team
Curriculum Designers & Educators

The TeachLessons team is made up of experienced classroom teachers and curriculum specialists from the US, UK, and Australia. We build complete, ready-to-use teaching resources because we know what it takes to walk into a classroom prepared. Every resource is grounded in real teaching practice, standards-aligned, and designed to make lessons better from day one.

Curriculum DesignK–12 EducationStandards AlignmentClassroom PracticeLearning Design
Common Questions

FAQ about TeachLessons resources

TeachLessons provides K–12 resources. Complete Curriculum packages currently focus on Middle School and High School, while the blog also supports Elementary teachers.

Each package includes lesson plans, worksheets, assessments, rubrics, and teacher notes as print-ready PDFs.

Yes. Resources align with relevant US standards such as Common Core, NGSS, and the NCSS C3 Framework.

Yes. Complete Curriculum packages currently focus on Middle and High School, while our blog supports Elementary teachers with lesson ideas, classroom strategies, cross-curricular activities, free downloads, and Teach-Life-Balance support.

  • Blog articles with practical lesson ideas
  • Free resources via the newsletter
  • Teach-Life-Balance for teachers at every level

The Teach-Life-Balance course is a time-saving programme for Elementary, Middle, and High School teachers. It helps with lesson planning, marking, admin, routines, boundaries, and workload management.

It includes a teacher planner, guides, templates, and practical strategies. Available at teachlessons.us/products/teach-life-balance.

After purchase you receive an instant email with your download link. Files are also stored in your customer account under Orders. Materials are print-ready PDFs for class, projection, or digital use.

Resources are licensed for personal classroom use. You may use them in your own classes. Sharing digital files or uploading them online is not permitted under a single-user licence. School licences are available on request.

Yes. Although primarily aligned to US standards, the lesson structures and subject content work well for UK and Australian classrooms with minor adaptation. The store supports GBP and AUD currency.

Keep reading

You might also like

Discussion

Comments

No comments yet — be the first to share your thoughts!

Leave a comment

Comments are reviewed before being published.

Also join the newsletter?
Get weekly lesson ideas and a free resource pack.

Please fill in all required fields and confirm your consent.

* Required. Email will not be published. Privacy Policy.

✅

Thanks for your comment!

Your comment is being reviewed and will appear here shortly.

Free resource inside

Lesson ideas straight to your inbox.

Join thousands of teachers. Sign up and get a free starter resource pack plus weekly lesson ideas — no fluff, just things that work in real classrooms.

No spam, ever
Unsubscribe any time
GDPR & COPPA compliant

Please fill in all required fields and confirm your consent.

💌

Almost there, !

Check your inbox and click the confirmation link to receive your free pack.

1
Check your inboxA confirmation email from teachlessons.us is on its way.
2
Click the linkConfirm your email to activate your subscription.
3
Receive your free packYour starter resource pack arrives right after confirmation.
No email yet?Check your spam or junk folder and mark us as “Not Spam”. Sender: teachlessons.us