Skip to content

Book Report #1

read time: ~5 min

Tags that this post has been filed under.

January is already in the history books, and for this month, (as promised) I have written a small book report on Grokking Algorithms by Aditya Bhargava. I couldn’t possibly cover every detail to the degree it deserves. Adit has already done a great job of that, but what I can do is highlight certain things that stood out to me.

There could be a mathematical explanation for how bad your tie is.

One of my favorite quotes from the movie Beautiful Mind. In a similar vein, there could be a mathematical reason for why something is slow, and algorithms can be the key to overcoming that challenge.

Why read this book?

Why, my dear sir, should I learn about these things?

Is this learning for learning's sake or are there practical implications?

Let’s understand something from the beginning. It is true even as a software developer that you may not be daily writing binary search or quicksort algorithms. Most programming languages have sorting and searching figured out for you. However, I would argue that understanding these concepts is vital to maturing as a serious software developer and even has broader implications all throughout life. Understanding algorithms and algorithmic thinking can make you a better problem solver, but if you intend to stay where you are and remain unaware of a beautiful aspect of this universe, by all means do not read further.

Let’s start by taking a minute to understand the term grok. What on earth does it mean to grok ? Let’s ignore our present day awareness of the term and its relationship with a certain technology. With limited context, I personally mistook it to mean doing something rapidly, but my cursory digging revealed it has a bit of a different original meaning. It’s believed that the term originates from a book titled Stranger in a Strange Land by Robert A Heinlein.

to understand a thing so thoroughly that you merge with it, and it merges with you.

To me, that seems more intentional than my previous, naive definition. To put it in my own words, to grok is to deeply understand a thing, which may in fact take a long time to understand.

I’m grouping the overarching topics of this book into three, distinct buckets:

  • algorithms
  • data structures
  • problem solving

algorithms

What is an algorithm? I’m glad you asked.

In my words, algorithms are a series of steps to achieve a certain result.

Let’s look at an example from everyday life. What if every time you wanted to drink coffee, you went all the way to the store and bought coffee first? That’s a rather suboptimal step considering you might have already had coffee at your house. To enhance your process (ahem, algorithm), you could check if you have coffee already and only go to the store if needed. As a further step, you could always grab coffee when your current coffee container is below a certain threshold, and you could schedule going to the store later. Now your original need of wanting to drink coffee is to simply make coffee. This is a natural algorithm that we have as humans, and if you sit and think for a bit, you can start seeing algorithms in everything (brushing teeth, washing dishes, blah).

Just as in life, some algorithms are just better than others. Better in what way? When comparing algorithms in programming, better means faster and or smaller. There are countless ways to achieve a result, but certain approaches are faster. How does one measure faster? With computers, we humans have coined an idea called Big O notation. It sounds a bit silly, but it literally means capital O for operations. Without taking a detour into logarithms land, just remember that Big O is shorthand for expressing the efficiency (or how fast) an algorithm is.

data structures

What is structured data? What is unstructured data?

When I think of unstructured data, I conjure up an image in my mind of a big box of lego bricks that have been mixed but not assembled. Providing structure is to create order or a pattern, and the structure is relevant depending on the end goal. Do you intend to quickly find a value? Do you need to keep things in a particular order?

Data is structured everywhere inside computers and outside. In programming, data is structured in a few key ways such as with arrays and hash tables; and they take their inspiration from real life things. Do you use shopping lists? Have you used a phone book or a dictionary? If so, you have been using data structures this whole time. You should congratulate yourself for practically being a computer programmer.

problem solving

So, how does knowing about algorithms and ways to structure data make me better at problem solving?

I would describe it as knowing when to apply an algorithm and/or data structure. Think of a toolbox. As you read this book, you will be equipped with a slew of different tools (ways to solve problems) that are each good at specific tasks. Knowing when to use a certain tool is the first step. Using a hammer to drive a nail is a great use for that tool. Using a hammer to mow the lawn will somewhat work, but it is not the most effective tool for that job.

By the end of this book, I found myself to be like a stranger in a strange land because this book made me aware of how little I truly know. I can’t say that I fully “grokked” this book either, but it did whet my appetite for many topics that I didn’t know previously, and I anticipate it will take several readings to fully tap into this deep well of knowledge.

If you have read this far, I commend your diligence. If you have feedback, hit me up on LinkedIn or through email (stephen@swaringin.com).

Now go read a book!