1 Introducing data structures


This chapter covers

  • Explaining why you should learn about data structures and algorithms
  • Understanding the difference between algorithms and data structures
  • Abstracting a problem
  • Moving from problems to solutions

So, you want to learn about algorithms and data structures: excellent decision!

If you are still deciding whether this is for you, I hope this introductory chapter can dispel your doubts and spark your interest in this great topic.

Why should you learn about algorithms? The short answer is to try to become a better software developer. Knowing about data structures and algorithms is like adding a tool to your tool belt.

Have you ever heard of Maslow’s hammer, aka the law of the instrument? It’s a conjecture, driven by observation, about how people who only know one way to do things tend to apply what they know to all kinds of different situations.

If your tool belt only has a hammer, you will be tempted to treat everything as a nail. If you only know how to sort a list, you will be tempted to sort your tasks list every time you add a new task or have to pick the next one to tackle, and you will never be able to leverage the context to find more efficient solutions.

The purpose of this book is to give you many tools you can use when approaching a problem. We will build upon the basic algorithms normally presented in a computer science 101 course (or the like) and introduce you to more advanced material.

1.1 Data structures

1.1.1 Defining a data structure

1.1.2 Describing a data structure

1.1.3 Algorithms and data structures: Is there a difference?

1.2 Setting goals: Your expectations after reading this book

1.3 Packing your knapsack: Data structures meet the real world

1.3.1 Abstracting the problem away

1.3.2 Looking for solutions

1.3.3 Algorithms to the rescue

1.3.4 Thinking (literally) outside of the box