THE BIBLE OF
ALGORITHMS &
DATA STRUCTURES
A COMPLEX SUBJECT SIMPLY EXPLAINED
BY
Florian Dedov
Copyright 2020
Website: https://www.neuralnine.com/
Other Books: https://www.neuralnine.com/books
Instagram: https://www.instagram.com/NeuralNine
YouTube: https://www.youtube.com/c/NeuralNine
Github: https://github.com/NeuralNine
TABLE OF CONTENT
Introduction
Algorithms and data structures are the nemesis of so many computer science students. It is a very abstract topic and it is oftentimes confusing for beginners. I personally think that one big reason for that is that it is oftentimes explained in a scientifically accurate but unnecessarily complex way. Most professors prefer textbook definitions rather than intuitive explanations. These are very important as well, because you need to be able to write down proofs and expressions in a scientifically accurate way. But especially at the beginning I think it is way better to focus on the intuition behind each concept first. Oftentimes it is easier to understand a complex concept using a metaphor, which is not 100% accurate but still good enough to give you the necessary understanding.
So thats what we are going to do in this book. Whenever we introduce a new concept, we will talk about it in a non-scientific way. We wont care about definitions that are mathematically correct 100%. The focus will be on getting an intuitive sense on what is happening. However, since scientifically valid definitions have their place, we will also work with those when they are beneficial and necessary. Sometimes we will use advanced mathematical notations and formal proofs. The main focus will nevertheless remain on the intuition of the concept.
Therefore this book cannot replace your university course or literature. It is more like a supplement for those who study computer science in college but also a great practical guide into algorithms and data structures for those who want to learn about this subject on their own. So if you just want to train your skills in this field on a practical level, without caring too much about all the formal details of mathematical notations, this book is a great choice for you.
Why Learn All This?
But before we get into it, let us answer a fundamental question here, that a lot of readers and students might be asking right now. Why should you learn all this? Why should anyone put effort into this subject, other than for passing the exam at college?
Let me give you a very practical reason first, before I get into the more technical stuff. Whenever you apply for a big software company as a programmer, database admin or networking expert, you will have a coding interview. And in most companies that you will probably want to work for (Apple, Google, Microsoft, Facebook), you will most likely get a question based on algorithms and data structures. You will be presented an abstract problem that you need to solve efficiently. For this you will need to dissect the problem logically, use proper data structures and apply efficient algorithms. If you try to come up with an inefficient brute force solution, you will probably not get the job. Therefore, for this reason alone, it is reasonable to master the field of algorithms and data structures.
But some of you might not only be interested in a job or a degree. You might want to actually become a better programmer or a better computer scientist, just for the sake of it. And in this case, there is literally no way around algorithms and data structures. If you are a programmer, you need to solve problems in an efficient way. If you are an ethical hacker or a cyber security expert, you need to understand runtime complexity, hashing and cryptography. If you are into machine learning, you also need to be familiar with all these concepts. Generally speaking, programming is not about learning a language like Python, Java or C++. It is fundamentally about problem solving. When you are given a problem, most of the time there are numerous ways to solve it. If you have never heard about runtime complexity and algorithms, you will probably (if you are able to find any solution at all) come up with a very inefficient way of solving the problem. You can almost always brute force your way into a solution. The issue with that however is that for some (pretty medium-sized) problems, you will have to wait millions if not billions of years before they are solved. Learning about algorithms and data structures makes you a better problem solver and that is what a programmer or computer scientist fundamentally is. It is not someone who writes code into an editor. There are people on Fiverr and Wish who do that for 5$ an hour. If you dont want to be replaced by those guys, you better learn how to solve abstract problems efficiently.
Structure of This Book
Now let us talk a little bit about how this book is structured and what you can expect. I already mentioned that our focus will be more on intuitive understanding, rather than on scientifically accurate definitions. For each concept we are going to start to learn about it by doing. We are going to use simple language and examples to understand what it is about. After that, if we decide it is useful, we might also cover the mathematically accurate formal definitions.
In the first few chapters, we will mainly talk about very fundamental and basic concepts. We will familiarize ourselves with the ideas of algorithms and data structures and we will look at how these two topics are interconnected. Also we will learn about runtime complexity, Big-O notation and analyzing algorithms. After that we will look at sorting algorithms and apply what we already know onto those. We will then get into the basics of graph theory, which is a fundamental mathematical subject of great importance in computer science. We will look at some interesting algorithms there. Later, we will mostly discuss the various different data structures there are and why you should or shouldnt use them in specific situations.
Generally speaking, we will work with a lot of examples and practical tasks. In my opinion thats the best way to learn about this subject. After reading this book, you should definitely be way more comfortable applying for a programming job or solving abstract and complex tasks in general.
Prerequisites
There are two basic prerequisites for this book. First of all, you should be familiar with basic coding principles. You should know your way around loops, if-statements, functions, variables, return values and you should have heard about recursion. These skills dont need to be in a particular language like Python or Java. A language is merely a tool. The concepts are what counts. This is important because we are going to work a lot with so-called pseudocode . This is code that is not limited to a particular syntax. It is easy to understand but only if you know these basic programming concepts. For the few practical coding examples in this book, we will be using Python, since it is the most similar to pseudocode.
If you want to brush up on your Python skills, you can also check out my book series called The Python Bible:
https://www.neuralnine.com/books
The second skill that you should have before reading this book is a high-school level understanding of math. I am not talking about partial differential equations here. I am talking about functions, logarithms, basic algebra, basic calculus etc. The only thing that you will maybe not have learned in high-school is the sigma sum notation. But we will briefly explain it in this book.