## Computational Thinking

When I was first asked to speaking at SCNA, I know exactly what I wanted to talk about, Computational Thinking and how early we can start. It was almost a year since we started working with my older son, Armin to teach him to think computationally and ask questions. As time passed and I was preparing for my talk, I started having doubts about whether or not this topic will be of interest to others, specially those without kids. I had these doubts until about an hour before my talk! During the talk, I was looking at the audience, seeing them engaged, nodding and laughing. That, of course, made me happy. I felt like I was able to connect with them. But after my talk, during the Q&A, I was pleasantly surprised and happy with so many people come to me and asked variety of questions from their own experience, learning in general, or teaching their children. One professor even came to me and talked about how he is trying to make education and programing fun for his students. One student mentioned that's how he felt about learning programing language but hadn't really seen anybody talk about it before. Another student said, he was introduced to programing syntax first before learning to think computationally, and he's been struggling with learning how to program.

It was very heartwarming to see I was able to connect to so many people at SCNA. Therefore, I decided to put the content in my blog and make it available to everyone. Hope this helps.

I've been an engineer for the past 14 years, but probably have been only thinking computationally for the last 7. To explain what I mean by that, let's start with talking about what computational thinking is NOT.

Computational thinking is NOT thinking in programming language syntax. I think the worst thing we could do to get someone interested in programming is to introduce them to syntaxes like Java, C, or Fortran on day one. Why would they want to bother learning these unfamiliar, arcane details like pointers, classes, and compilation? Rather, let's start with a goal. What problem are they trying to solve? Can this problem be framed as a computational one that a computer can do much faster than we could?

**why**the program was going to work before I even wrote it.

The computation I wanted literately to do included things like:

My mother is a retired elementary teacher, and most of her career she taught first grade. She had performed these computations for a long time! Her and I put a curriculum together which I then I used Ruby on Rails to build the application and put it online for free as literately-Farsi!

There’s this famous quote:

"Computer science is no more about computers than astronomy is about telescopes."

Sure, I agree with it to some level, but learning about astronomy without **ever** using a telescope, I'd wager, would be really frigging hard.
Learning to think computationally without ever writing code or using computers, similarly, holds back a learner.
I think the question is really about **when** to introduce code, not if.

So this raises two questions:

- How early can we introduce computational thinking?
- How early can we introduce programming?

Let’s look at the Fibonacci Sequence example n = (n-1) + (n-2):

Without using any “computational devices”, most of us will slow down around the 10th digit. Let’s see this in action, try this along with me.

Given 0 (n-2) and 1 (n-1), what comes next in the sequence?

.

.

How many numbers we were able to calculate before you slow down?

Of course some of you geniuses can go easily up to 15…20…30…digits. But you’re weird…in a good way! :)

How about this one?

**What's the 100th number in the Fibonacci sequence?**

How long would it take a human brain to get this answer? And how likely would we be to make a mistake along the way because of a bug in our brain’s programming?

This is where a computer can really help us out.

- How long does it take for us to write that in our language of choice
*once we know an algorithm to generate the sequence*? - How long would it take for a computer to run that code?

Clojure syntax:

Now it's find out the 100th number:

**345,224,848,179,261,915,075**- Elapsed time: 0.059953 msecs

Now not all implementations of this algorithm will be this performant!

**Computer science**, especially programming language theory and implementation is what lets us have a conversation about things like lazy sequences, tail-call optimization, and stack frames.

**Computational thinking**, on the other hand, is what lets us design an algorithm that can produce the Fibonacci sequence in the first place…with or without a computer.

Before we write the code, we need to frame the problem in a precise, repeatable recipe, **an algorithm**. What needs to happen in between the inputs we have and the output we want? How will these inputs and outputs be modeled? What data structures will we need for that modeling?

I’ll make the claim that there’s nothing the computer can do that the human brain cannot, given enough time and memory.

#### Are the computers always faster and more efficient?

Noisy image recognition is a computational problem that humans can do subconsciously, but that computers struggle with. We could have a whole talk about the work going on with artificial neural networks to solve this type of problem, but what if we just put a human brain to work, for now?

And that’s what Luis Von Ahn did!

This is an example of what our brain can read and comprehend with one look but computers are not yet sophisticated enough to do. Most humans can't do numeric manipulation quickly. Most computers can't do free-form pattern-matching the way our brains can.

This is Grady Booch, he’s a software engineer and some of us might know him as one of the guys behind UML… but he’s spending much of his time these days in computation and AI.

I love this quote from him:

Story of computing is the story of humanity!

Computing started out as human computers, mostly women. Computation, preformed mostly by women, in WWII was one of the key factors we won the war!

In one of his articles, Grady mentions:

Computational thinking drove our imagination, it goes beyond what computers can do and what we can do in present time

**We are still the most extraordinary computers of all.**

How do we gain skill in

**consciously**thinking of problems computationally? And if we can do so as adults, how early can humans start? Can we make computational and mathematical thinking like a second language at home to teach our kids while we practice ourselves?

- How do I prepare my children to be excited about problem solving in their world?
- How do I teach them to look at numbers and analyze the facts, not just listen to other people’s opinions?
- How I prepare them to take a complex problem in life and break it down till they find a solution?

Now let’s talk research ethics here for a second. Before you accuse me of being a mad scientist and treating my kids like minions, let me show you some of the homework I have done.

When we were expecting our first child six years ago, we were complete apprentices in parenthood. So my husband and I started reading a lot of books and watching a lot of documentaries about early childhood education and infant brain development.

At just a few months old, babies can:

**predict sequences of events:**

- running water => bath time
- mommy goes to fridge with a glass => water
- putting shoes on => go outside

**Connect cause and effect:**

- shaking a rattle => makes a sound
- pushing a toy off the table => drop, bang…the joy of gravity!
- cry => Mommy or Daddy will pay instant attention and maybe pick me up.

**Understand relative sizes when the ratio is at least 2:1**

- babies are small / parents are big
- line 1 is shorter than line 2

Babies are born with innate capacity for understanding numbers. This is an amazing video done by psychologists at Karen Waynn's Lab at Yale University.

In this segment, the researchers show a doll to a six-month old in a setup similar to a puppet show. Then a curtain covers the stage where
the doll is sitting, and the child could see another puppet go behind the curtain. Then the researcher sneakily removes the first puppet
without the baby being able to see it. The curtain falls and only one puppet remains.

**1 + 1 = 1?**

The baby is astonished and starts staring and banging the table! Every time the curtain was lifted and the answer was what they expected,
however, the baby looked bored and looked away after only a few seconds. Dr. Wynn and her team replicated these results with six-month olds
and even four-month olds, demonstrating that babies recognize addition and subtraction if only subconsciously.

Think about that! A baby can recognize mathematical inconsistency in the real world years before they can recognize a grammatical model of
the world like “2 – 1 = 1”!

If you look into the eyes of a 6-month-old child, when he or she is in the park, you will notice that she is performing computation and analyzing the world around her. How far mommy is, how she can get her attention, or grab her favorite toy.

As we see in this graph, so much is happening in the first year of a baby’s life. There are roughly 2,000 days from the time a baby is born to when that child begins Kindergarten. Kids aren’t just on a five-year vacation before they start in the K-12 school system!

Babies are born with 100 billion neurons, roughly about how many stars are in Milky Way and that’s about all the neurons we will ever have. But only about a quarter of the connections - synapses - are already made between them. The young brain makes billions of new connections with every bit of knowledge that is taken in, in order to make sense of it.

By age 2, the brain has up to twice as many synapses as it will have in adulthood. While the brain cells are formed before birth, the connections, the wiring that forms the architecture happens in infancy and early childhood. And how that wiring is formed, either as a strong or weak foundation depends on each child’s interactions with the world around him/her.

Of course that doesn’t mean as we age we’re not capable of learning new skills or enhancing them but it requires more effort. So much of we use now are the connections that we have built early in our lives and those that are not being used will get weaker and weaker.

Given the impact on brain development, it’s not surprising several studies emphasize the significant long-term impacts of creative environments.

In a great book, Mindstorms, Seymour Papert suggests we look at Mathematics as a second language.

Kids are pressured in K-12 to learn STEM after potentially having gone those 2000 days without mathematical or computational thinking. They can become afraid of math because of the unfamiliarity of material like symbolic notation as a model for a real-world pattern, the lack of immediate feedback, and a fear of failure of not being a “math person”.

#### Be Patient when Learning!

Dr. Maryam Mirzakhani was a mathematician and professor at Stanford University, sadly passed away a few months go. She was well known for being the first female who won the most prestigious award in mathematics, the Fields Medal, in 2014.

The beauty of mathematics only shows itself to more patient followers.

When learning mathematics, or any complicated algorithm for that matter, we have to be patient and allow our brain to deeply understand the problem, and to enjoy the path to solve it.

Now that we know math and computation are essential, where do we start? For kids or ourselves? Let’s not forget, it’s not as though every K-12 is already a programmer and computational thinker, they’re going to need to learn, too.

The first place that I started and personally love is sorting laundry! That’s not just education, that’s task delegation!
**How do we turn a basic daily chore into a computational thinking exercise?**

Organize the closet by type of cloths, color, sleeve length and so on!

#### Merge Sort!

Merge sort is a great solution!

How many people know this algorithm off the top of your head and can live code it like we’re in a bad job interview?

Better yet, how many of us who use a pre-implemented solution or can code it, could show us what merge sort looks like without a computer?

- Divide the unsorted list into n sublists, each containing 1 element (a list of 1 element is considered sorted)
- Repeatedly merge sublists to produce new sorted sublists until there is only 1 sublist remaining. This will be the sorted list.

#### Merge Sort - Ruby Edition!

This is one example of merge sort in ruby:

We don't want to get hung up on teaching classes in Ruby or any other syntax yet. Rather, we need to build some intuition in the child about different sorting algorithms and how merge sort might work in particular.

Remember the first step in computation was, decomposition and understanding the problem. Last step is to instruct the computer to do it

In case of Armin, he likes cards and poker! Why not start with sorting there?

The first time I asked him to sort a stack of cards, he starts with an intuitive but computationally inefficient approach. Of course he looked for 1, then 2 and so on…

Then without saying much I started the merge sort and he became interested. I introduced it as a game that always produces a consistently correct result. Inevitably, he started arguing that his approach is much better. But, what if we’re sorting stack of 20, 30, 40, 100 cards? And soon he realized he want to learn a better method.

He also likes to know that the work he does is valuable and appreciated. So he was more than happy to make this video and explain how he does the sorting!

Not only did he get an introduction to sorting, but he’s already seen his first divide and conquer algorithm. Divide and conquer is a family of algorithms and a useful pattern, and shows up in politics from time to time as well…something for another talk, perhaps.

Once he was comfortable with the algorithm and had done a fair amount of debugging, I introduced **iteration** and timing.

Keep in mind that patience, persistence, and repetition are very important character traits during practice. This is what gives us the tolerance for failed attempts, letting us learn from them instead of simply giving up. This is how we build deep learning, understanding, and mastery.

#### Set

Marsha Jean Falco invented this game in 1974 and introduced it to outside in 1990! There’s a really cool history behind it; I won’t go to the details but you’re welcome to read it.

The goal is to find three cards where each feature, when looked individually is either all the same OR all different.

Each card contains four features:

- color (red, purple or green)
- shape (oval, squiggle or diamond)
- number (one, two or three)
- shading (solid, striped or outlined)

When playing, the first person to see a SET, calls out and picks up the three cards that makes the SET. The person with most SETs (or cards)
wins.

This is a speed game that encourages the players to apply the logic and speed in order to win.

It turns out that sets are also very important in mathematics. The language of set theory can be used in the definitions of nearly all mathematical objects and is commonly employed as a foundational system for mathematics. Once we understand the set, then we can apply other computations such was union and intersection to it.

## In naive set theory we assume the existence of some given domain of “objects”, out of which we may build sets. Just what these objects are is of no interest to us. Our only concern is the behavior of the “set” concept.

The Joy of Sets

The Set game makes the concept of sets fun.

When we eventually introduce the programming concept of a Set, like the Clojure sets here, Armin will have some familiar concepts to fall back on.

The shared information of the physical should ease the jump from the physical to the abstract, and vice versa.

Theory: The information learned from computational thinking about the familiar physical world makes it easier to model that information in a programming language later on in a potentiallyunfamiliar virtual world…and vice versa.

#### Cubetto

Let’s build on this theme of connecting computation in the physical world with programmatic models in the computer.

Sometime earlier this year, I ran into this cute but purposeful toy on Kickstarter to teach kids to start thinking programmatically. It sounded very interesting. At the time, I thought it would be just too early for Armin to start, since I hadn’t even started the techniques we just talked about. Eventually sometime around April or May, I ordered one and it’s been great! Cubetto is inspired by Turtle math to translate real-world thinking to a programming language and it’s been approved by the Montessori

Let’s see Armin’s interaction with Cubetto 101! As we see, this robot doesn’t have a screen. However, each step blinks on the board when functions are used as well as the step that's being executed, while Cubetto is performing it so the child can make the connection.

Here is another great thing: Before Armin put in the commands, he pseudo-coded the algorithm he wanted Cubetto to execute on his notepad!

Then when we started putting the commands on the board, Armin realized it’s a pattern. He used a function block to define the pattern, DRY up his “code”, and run the program!

- Visually seeing bugs and fix them
- Algorithm development
- Functions

Here we come back to Keith Devlin’s work: Mathematics is the science of patterns. A big part of mathematics is describing some pattern we
observe in the world in a way that is precise, repeatable, and provably correct. Sometimes those patterns are numeric, sometimes geometric
and sometimes they’re patterns of human social networks.

At the end of the day, this is a big part of what we’re doing as programmers.

#### LOGO

For Armin, the next step, when he’s ready, is to project his patterns on the computer.

Learner can then take a step farther and come up with some absolutely beautiful designs. Take a look:

For the pythonista’s in the audience, there’s python-turtle

#### Degrees

Now we bounce back from the virtual to the physical. Before we introduce Armin to these kinds of drawings, we need to teach him about angles!

Now this is how our conversation goes most nights:

Armin: Con you please leave my door cracked?

Mom/Dad: What angle?

Armin: 90°

Mommy: Hey, that's too much! How about 5°?

Armin: Fine, I will meet you in the middle... 45°

Unintended side-effect. He really does negotiate this way, completely one-sided

Final: 10°

#### STEM Workshops

In addition to spending 1:1 time with our kids, we can also take advantage of programs that are design to encourage STEM in early childhood education. One of these organizations is Blue\|1647.

For those who are not familiar, Blue\|1647 is a technology innovation center and this even was designed to encourage children as young as 4 years old to approach problems in scientific way.

Recently, they had an event in April that I volunteered for. I worked with a group of 8-10 years old on a day full of STEM workshops. For example, we design a parachute that safely lands an egg… just use your imagination how the place looked liked after that. Or try making a paper airplane that stays in the air longer and travels a longer distance… test, redesign/debug, and test again.

These are the techniques that are so crucial in computational thinking and when put in such fun way, it encourages the children to learn them without thinking they are learning STEM.

When learning mathematics or learning to look at a problem computationally. Be very patient, be persistent and allow ourselves or the learner to digest the information without being under the pressure. Don’t set up high expectations, don’t take shortcuts to meet those expectations. Let things progress naturally

- Be patient
- Be persistent
- Do not set high expectations
- Do not teach programing syntax yet
- Make it about day-to-day life, be precise
- what temperature should the oven be on?
- how many more minutes you need to play?

- Let the child manage money
- Show them fractals
- Have them watch our speed when driving (warning: this could be problematic!)
- Don't fear mistakes!
- When we are not wrong, we don't come up with anything original! We are pushing and expecting our kids to be always right; and that's how we take originality and creativity away from them.
- Learn from attempts, don't fear them. Celebrate the effort, the pride form the wins will come naturally. Encourage children to keep trying and become resilient to things not working.
- Revise our work, change our methodologies!
- Don't tell our children they are smart, even if the tests say are! It dismisses the hard work they are doing, and have to continue doing, to achieve their goals.
- Let our children get bored from time to time to encourage their creativity.

Jeffery Karpicke is a 10-year faculty staff at Purdue University, in Cognitive Psychology department.

- Human Learning and memory, especially retrieval process
- Cognitive Science and education
- Complex Learning, comprehension, and knowledge application
- Learning and cognitive strategies in children
- Metacognition and self-regulated learning
- Education technology and computer-based learning

Karpicke and Bauernschmidt did a research projects on about word-learning in 2011. They wanted to see how do we learn and persist information in long term memory. In this research, students were going to learn words like "mashua" in Swahili.

Students were divided into 4 groups. They were shown the words, and it’s translation, then they had to type the translation (recall). In one week they would be tested to see how much they remembered.

Learning:

- Group 1: studying without recalling
- Group 2: study, recall them till they had answered them right, then the word would drop out of the list
- Group 3: this group was practicing
**massed retrieval**practice where the word was shows and was repeated 3 times immediately for retrieval - Group 4: Repeat 3 times but with
**spaced repetition technique**

**Repeated retrieval with immediate feedback leads to long term retention- Jeffrey Karpicke**

So next time we are learning new information, let's keep Jeffrey Karpicke’s research in mind and give it try!

This is a proud parent moment I wanted to share with you and the importance of looking at Math as a language!

By now, you know that this blog was just an excuse for me to show Armin’s pictures because he’s so cute... last one, I promise!

A couple of weeks ago, Armin came to my husband with this drawing from his class. He first filled the color palettes and then realized that there are mix of primary and secondary colors, He knows yellow and blue make green, for example. So he decided to connect the secondary colors to the primary colors that make them. He made an arrow going out of black, because he thought black is a combination of all colors! This was amazing to us, because we’d never explicitly taught him this. But for those who know Bobby and have attended his talks, you know he loves networks and the kids have seen him working on graphs many times. Armin connected the colors and created a graph and he showed it to Bobby saying, “Look, Daddy… a graph!” Bobby was so proud and told him he’d made a color dependency graph.

Mom and dad this picture is for both of you, this is my first graph!

- linkedin/felfli
- sarah@testedminds.com