Richard Wiener
Colorado Springs, CO, USA
ISBN 978-1-4842-8190-1 e-ISBN 978-1-4842-8191-8
https://doi.org/10.1007/978-1-4842-8191-8
Richard Wiener 2022
This work is subject to copyright. All rights are solely and exclusively licensed 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.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use.
The publisher, the authors, and the editors are safe to assume that the advice and information in this book are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the editors give a warranty, expressed or implied, with respect to the material contained herein or for any errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
This Apress imprint is published by the registered company APress Media, LLC, part of Springer Nature.
The registered company address is: 1 New York Plaza, New York, NY 10004, U.S.A.
Introduction
This book is aimed at practicing Go software developers and students who wish to experience the excitement and see the benefits of data structures and algorithms in action. Because of its clean and readable syntax, outstanding support for concurrency and generics, and execution speed, Go was chosen to present the implementations of the data structures and algorithms along with many applications. It is assumed that the reader has basic familiarity with Go. The numerous code listings and their explanations will hopefully serve to improve your programming skills using Go.
The latest version of Go, Version 1.18, features genericity (generic and constrained generic parameters for data types and functions). This long-awaited addition to the Go language is ideally suited for use in building reusable data structure packages. Prior to Go Version 1.18, separate implementations of data structures and their associated algorithms were limited to a particular data type. So, for example, a list containing information of type int would have to be reimplemented if the underlying type was, for example, changed to float64 or to a more complex user-defined custom type. With the new Version 1.18 of Go, generic and constrained generic data types remove this severe restriction. Generic and constrained generic data types will be featured throughout this book, and all source listings will use Version 1.18 of Go.
Computer science, like many sciences, has many areas of specialization network security , e-commerce, general web application development, graphics, game design, database applications, encryption, natural language processing, text analysis, compiler design, operating systems, simulation, machine learning, and AI, just to name a few. Knowledge of the effective design and use of data structures and algorithms are useful in these areas of specialization and are therefore a fundamental part of computer science and software development methodology.
Over the years and because of application development in the areas mentioned and not mentioned previously, a consensus has emerged about which data structures and algorithms have the greatest utility. Nothing is static in this area, so new data structures and algorithms are being designed. The task of successfully advancing and moving ahead as a developer is greatly enhanced by studying the great works already established. The goal of education is learning how to learn. In the context of this book, the great works are the data structures and accompanying algorithms that have been shown to have utility in a large variety of computation problem domains.
This is not a theoretical book laden with formal proofs. There are many such books already available. For the data structures presented, not every use case is included. It is hoped and expected that after focusing on the major data structures and associated algorithms presented, the reader will be better prepared to extend their knowledge as they move forward in creating or discovering new data structures and algorithms. It is also hoped that by presenting a variety of problems that are solved by hitching a ride with one or more of the data structures and algorithms introduced, the reader will appreciate the power that mastery of this subject matter brings to the table of software development.
The use of concurrency in implementing data structures is a major feature of this book. Concurrent implementations are utilized whenever appropriate throughout the book.
Chapter presents a tour of generics and concurrency in Go.
Chapters present classic data structures and algorithms and show them in action. These include sorting and searching, stack, queue, lists, deque, hash table, binary search tree, AVL tree, red-black tree, heap, expression tree, and graph. Many examples and applications are presented. Dynamic programming and branch-and-bound algorithms are used to solve classic problems such as shortest path in a graph and minimum spanning tree.
Chapter , which present heuristic solutions to this problem.
Chapter presents a simulated annealing heuristic solution, which is shown to be very effective in solving large TSP problems.
Chapter presents a genetic algorithm, another effective heuristic solution to TSP.
Chapter introduces machine learning and neural networks. A neural network is constructed from scratch and used to train a network to evaluate medical test results.
In summary, this book will
Explore classical data structures and algorithms aimed at making your applications run faster or require less storage
Use the new generic features of Go to build reusable data structures
Utilize concurrency for maximizing application performance
See the power of heuristic algorithms for computationally intractable problems
Enhance and improve your Go programming skills