Teaching AP Concepts in Scratch – Vol II – Searching

A typical linear search algorithm consists of some variables, an if-statement, some type of loop, and of course a list.  The search may be examining the list and looking for a specific value or some type of thing, like a specific type of creature, the prettiest princess, or an animal in a game.  I do not write games about pretty princesses, but I do have students that like to do that.

The AP A exam tests a student’s ability to solve problems and formulate algorithms.  The exam does use Java as a testing vehicle, but does not test specific syntax details of the Java language.  First and foremost, the AP A exam is focused on testing a student’s problem-solving ability.  Searching a list requires a certain amount of problem solving ability at a very basic level.

Searching through a list for something is a very important Computer Science concept and one that is tested on the AP A exam.  Typically, the AP exam free response will ask a student to write an algorithm to search a list for something.  The multiple choice component of the test usually contains a question or two focused on searching as well.  Students need to understand this concept very well.

Searching in Scratch and in Java.

Searching in Scratch and in Java.

Writing a search in Scratch is relatively the same as writing a search in any language or environment.  Students still have to combine some variables, a loop, and an if-statement together to process a list in order to solve the problem.  The main benefit of doing this in Scratch first is that students can just focus on the problem as they have to spend considerably less time on the details of typing in all of the pieces.  Scratch does not require that students focus on syntax details so students can concentrate solely on how to solve the problem.  After mastering the concept in Scratch, it will be much easier to crank out a solution in a text-based language like Python, Scala, PHP, Ruby, or even Java.

Scala is a pretty slick language by the way.  A good friend at Rice University suggested I check it out.  It is pretty cool.

Using Scratch BYOB makes creating a search in Scratch a bit slicker as you can create your own blocks and pass parameters.  This adds in a bit of abstraction that you do not have in the non-BYOB version of Scratch.