Sorting Pairs of Cards With a Cache

Students are shown the idea of lookup table (cache or hash table)

SubjectMathematics, Science, Computer Science
Length90 minutes (2 x 45 minutes)
Pedagogical ApproachHaptic Learning
CompetencesProblem Solving, Algorithms
Grades3rd-6th grade
TechnologiesNo Technology

Other Materials Needed
Memory playing cards

Key Competencies for Students

  • Understand what a cache is and how it works
  • Understand what a hash table is and how it works
Description

Introduction
Teacher tells students to find all the pairs from the shuffled memory deck. Students have to count every time they look at a card. The less times cards are looked while pairing, the more efficient their sort algorithm. Students can start with 10 to 20 pairs of sortable cards and can go up to 100 pairs. They are told they should come up with a tactic (algorithm) and then follow it through all the way. Teacher can make a reference to the human robots exercise. The tactic, amount of cards and the count are written down.

Αctivity 1
Cards are turned face down on the table or on the floor. Every time a student looks at a card they add one to their count. Card is looked at and then turned back facing down. This is continued till all the pairs have been found. There are several different tactics for this and students can be left to found them on their own. (30 minutes)

Discussion: When all students have tried out sorting a couple of times, they can be asked if they can come up with a tactic that is working better. Teacher introduces the idea of a cache: every time a card is turned, it can be left in a row facing up. When a card is turned from the table it is compared to the row from the beginning. Every time a card is compared to a card in the row (cache) the count is increased by one.
(15-30 minutes)

Αctivity 2
Students try out sorting with the cache with the similar amounts of cards they used earlier (As much time as wanted, about 5 min / sort) and write down the counts.

Discussion: See the results for different kinds of tactic/algorithms and talk about them. Does the cache help? (10 minutes)

Evaluation Tools

Teacher led discussion afterwards

Leave a Reply

Discover more from Computational Thinking and Acting

Subscribe now to keep reading and get access to the full archive.

Continue reading