Your programming roadmap

Data Abstraction

lists and trees

We use functions to encapsulate and hide details about a behavior. Likewise, we use data abstraction to hide details about how data are created and used.

Consider using the apply first, study second approach with the resources below: try a problem or exercise from the Apply It section first. If you get stuck, then use a course, book, or lecture in the Reference section. Or if you’re completely new to a topic, then learn just enough and apply right away. The point is: the quicker you get to the “doing,” the better the learning. Make your learning active.

Apply It

Lab 5: Data Abstraction, Trees from the Berkeley course CS 61A: Structure and Interpretation of Computer Programs will ease you into trees and linked lists. This lab is a good introduction to data abstraction, with quality command-line exercises and code-writing questions. Plus, it’s free! This short video will show you how to access the files and run the tests for Lab 5.

Hal Abelson’s book, Structure and Interpretation of Computer Programs (SICP), which is free online, is a great resource. Not only for its content (see the section below). But also for the number of exercises found throughout the book. For our purposes here, focus on chapter 2.

Tip: SICP uses the language Scheme, which is a fantastic language to learn. Simply Scheme by Brian Harvey and Matthew Wright is a useful book to help you learn and get practice with Scheme.

AlgoExpert is an all-around great resource that offers tree and linked list problems (among many others). After you sign up, then sort the problems by category, and you’ll find the ones related to trees and linked lists. I mention AlgoExpert several times throughout the Pyramid, and it’s worth another mention here. Yes, you’ll get practice with trees and linked lists. But—and this is the critical point—you’ll really come away with a solid understanding of them.

That’s because AlgoExpert offers a video explanation for each problem, which contains a conceptual overview of the problem and code walkthrough. This is a point of distinction, and I can’t stress how important it is to take the time to watch, study, and work through these videos once you’ve solved a problem. They’ll clue you into the why, when, and how of trees and linked lists, or whatever data structure or algorithm you happen to be focusing on.

Tip: Try a learning approach that I call “Multiple Streams of Learning” (MSL) as you learn new topics. The idea is to learn a subject or build a skill from multiple perspectives. Here’s how MSL can work with data abstraction:

  • Solve a “tree” problem on LeetCode, and study the solutions offered in the “Discuss” tab.
  • Solve a “tree” problem AlgoExpert and study the solution: watch the provided video lecture and study the provided solution(s).
  • Reference one of the books or courses in the Reference section below to dive into a question or trouble spot.
  • Solve the problems in Lab 5.
  • Repeat the “tree” problem from AlgoExpert, but use a technique or approach that you learned from the video.

The idea is to attack a topic from multiple angles, which you’ll do by following the example above where you access and use a variety of resources. This approach will help you to make connections and solidify concepts. Plus, you get a range of perspectives, which fosters an open mind. And it’ll help you to nail the details: what you may overlook in one resource you’ll pick up in another.

LeetCode is another platform that I mention throughout the Pyramid. It’s useful here, too, because you can filter the problems by topic and difficulty. So filter the problems tagged as “Tree” and “Linked List.” Plus, the solutions and community discussions offer useful insights.

LeetCode also offers an “explore” section that contains instruction and several practice problems on select topics, including linked lists and binary trees.

"It is hard to fail, but it is worse never to have tried to succeed."

-Theodore Roosevelt

Reference

In addition to problems, AlgoExpert also offers a Data Structures Crash Course which includes video lectures on linked lists and trees, among other data structures. The lectures are clear and don’t assume too much. You’ll come away with a solid understanding of the topic at hand.

Then, as you get more familiar with data abstraction, reference the following free lectures from Berkeley’s CS 61A course: Structure and Interpretation of Computer Programs:

Or reference chapter 2.2 and chapter 2.3 in John DeNero’s free electronic book, Composing Programs.

As mentioned in the Apply It section above, Hal Abelson’s book, Structure and Interpretation of Computer Programs, is a great resource on the topic of data abstraction (see chapter 2). It’s filled with exercises, but also useful content.


← Back to Programmer's Pyramid