Armstrong Subero
Basse Terre, Moruga, Trinidad and Tobago
Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the books product page, located at www.apress.com/9781484257241 . For more detailed information, please visit www.apress.com/source-code .
ISBN 978-1-4842-5724-1 e-ISBN 978-1-4842-5725-8
https://doi.org/10.1007/978-1-4842-5725-8
Armstrong Subero 2020
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein.
Distributed to the book trade worldwide by Springer Science+Business Media New York, 1 New York Plaza, New York, NY 100043. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
Introduction
There is one question beginners and even good self-taught developers ask me all the time: How do I learn data structures and algorithms? I have had to answer this question so often that I thought I would write it down in a book so that anyone interested in this topic could follow along and understand the process.
The thing is, anyone can learn the basics of data structures and algorithms. There really isnt much to them. The hardest part of teaching someone this topic is that they are likely to be using any language from the current zoo of languages. They may be using Python, Java, C++, or even C or Rust. Whatever the language they are using, it is important to be able to understand data structures and algorithms at the fundamental level. As such, I decided to make my book codeless. This is a book on algorithms and data structures that doesnt use a single line of code from any programming language.
As someone who must regularly change between different programing languages, take it from me, once you understand the concepts behind these algorithms in a codeless way, then you will be able to apply them to whatever language you are using.
There are also some people devout in their programming language who are unwilling to look at any material that isnt in their language of choice. As such, I have written this book without offending anyones beliefs. I think there are enough books on data structures and algorithms in X language that are thousands of pages detailing programs and all their nuances for the language you are using. I think such books would be fine complements to this one, as this book will give you the big picture, and then you can look at whatever book you want for the rest. You can learn about a concept here and then go to that book to learn the programming details.
Everything is explained in plain English, and each chapter is short and to the point. You will learn a lot without burning your brain out.
Who Is This Book For?
This book is for people who want to understand data structures and algorithms but dont want unnecessary details about quirks of a language and dont have time to sit and read a massive tome on the subject. This book is for people who want to understand the concepts of algorithms and data structures in plain English. I assume, though, that you have knowledge of at least one programming language, preferably a C-based one such as C, C++, Java, C#, or Python. The types and terminology used in this book are biased toward people who have used one of these languages.
I assume you are good at thinking abstractly and at least have basic knowledge of a programming language and of the basics of computer science (what a bit is, what a byte is, etc.). I also assume you know basic mathematics, at least algebra, though this book is by no means a math-heavy book. I use math concepts only where they are necessary and explain them clearly.
What Will I Need for This Book?
You wont need anything except an open mind and time to read and understand the concepts being presented. I wrote this book as if we were having a coffee and I was explaining these concepts to you from the top of my head. For that reason, you wont need any compiler or text editor, just a listening ear.
What Will I Learn in This Book?
You will learn quite a lot in a short space of time about data structures and algorithms. You will learn the concepts of data structures and algorithms with a focus on the most relevant ones in simple, plain language. After completing this book, youll understand which data structures and algorithms can be used to solve which problems and will be able to confidently follow along with discussions involving algorithms and data structures.
PART I Data Structures
Chaptergoes into what algorithms and data structures are, and we discuss primitive types and Big O notation.
Chapterlooks at the linear data structures of arrays and linked lists; we also discuss stacks and queues.
Chapterdelves into trees and tree-based data structures.
Chapterintroduces you to hash-type data structures.
Chapterbriefly covers the basics of graphs.
PART II Algorithms
Chapterintroduces two common algorithms, that of linear search and binary search.
Chapterexplores sorting algorithms, including bubble sort, selection sort, insertion sort, merge sort, and quick sort.
Chapterpresents some search algorithms; we look at breath-first search, Dijkstras algorithm, and the A algorithm.
Chapterintroduces clustering algorithms, specifically the K-means algorithm and K-nearest neighbor and get a taste of machine learning and neural networks.
Chapterteaches some basics about the concept of randomness.