Scaffolding and Trees

Lauren Gifford
Nerd For Tech
Published in
4 min readApr 30, 2021

Building and growing strategies from nature and beyond.

What’s the first thing you think of when you hear the word Scaffolding? For me, it’s walking down the sidewalk in NYC and suddenly fearing for my life because there are people on ladders building large structures to cover the sidewalk for the purpose of protecting pedestrians like me from falling construction debris.

In Psychology and Education Theory there is a rather different concept also known as Scaffolding. In Psychologist terms:

“Scaffolding is an instructional technique in which a teacher provides individualized support by incrementally improving a learner’s ability to build on prior knowledge.”

Basically, it is the idea that it is far easier for someone to learn a new concept by building on the knowledge they already have which has similarities to the new knowledge. When learning programming, I found myself constantly trying to fit new pieces of information into my brain by telling myself what this thing reminded me of that I already knew. I was scaffolding for myself because, let’s face it, learning new things is hard and even more so when you have no frame of reference about the new thing.

Trees (natural and programmatic) are actually a great visual representation of the concept of Scaffolding. We begin with one node / piece of knowledge, and slowly build on it, connecting pieces of data based on relationships we see to other pieces of data.

I wanted to demonstrate how the scaffolding thought process might work by talking through introducing myself to a new concept. Let’s discuss our leafy friends.

I want to learn what a tree is as a data structure. First, we do some Googling and see:

“A tree is a data structure where a node can have zero or more children. Each node contains a value. Like graphs, the connection between nodes is called edges. A tree is a type of graph, but not all graphs are trees.”

And a picture!

This image sums it up nicely

My mental model of a Tree is now that it’s like a green tree in that there’s a tree trunk (root node), branches (subsequent child nodes), and leaves (nodes at the end of the structure not connecting to additional nodes).

Now I would like to understand a couple of things.

  1. Why do we need these?
  2. How do we use them?

The Why

Trees with two child nodes per parent node, known as Binary Trees, or Binary Search Trees depending on the order in which the children fall on either side of the parent, are particularly useful for efficient sorting and searching. Thinking for a minute about what I already know about how sorting and searching on a data structure like an array requires at least one loop and sometimes multiple, I’ll accept that a structure which already has some implemented logic of the relationships between information can be highly effective at locating a specific bit of information.

The How

I would like to explore how Binary Search Trees can provide an efficient searching framework using recursion. I have used recursion before when working with arrays so I can apply that experience to working with trees. An array is made up of sub-arrays just like a tree node is made up of other nodes!

A BST requires that data to the left of the parent node is less than data stored on the parent which is less than data stored to the right. Knowing this relationship, we can write a function which takes in a root node and a new node. If the current node is null, this function will compare the data stored at the root and new nodes, inserting it to the left if less and to the right if greater. If the current node does exist, we send the current and new nodes back through the function until we arrive at a blank node which we can insert the new node into. As we traverse the tree in this way, we are checking the data at each current node against the data stored at the new node and if it matches, returning it.

Binary search or insert algorithm

Let’s reflect

What have I learned about trees?

  • They are super useful for modeling relationships between data.
  • I can use my knowledge of recursion to help traverse and search them.
  • They make a really compelling mental model that’s easy for my brain to remember and add to.
  • Ideal for scaffolding!

The last piece of the puzzle in scaffolding knowledge is practice. Now that I’ve built this new data structure into my tree of knowledge, I will need to practice at every opportunity to solidify my knowledge and grow new leaves and branches!

--

--

Lauren Gifford
Nerd For Tech

Front-end Engineer | Project Manager | Tech Enthusiast -- Open to opportunities