Book Image

Learn Data Structures and Algorithms with Golang

By : Bhagvan Kommadi
Book Image

Learn Data Structures and Algorithms with Golang

By: Bhagvan Kommadi

Overview of this book

Golang is one of the fastest growing programming languages in the software industry. Its speed, simplicity, and reliability make it the perfect choice for building robust applications. This brings the need to have a solid foundation in data structures and algorithms with Go so as to build scalable applications. Complete with hands-on tutorials, this book will guide you in using the best data structures and algorithms for problem solving. The book begins with an introduction to Go data structures and algorithms. You'll learn how to store data using linked lists, arrays, stacks, and queues. Moving ahead, you'll discover how to implement sorting and searching algorithms, followed by binary search trees. This book will also help you improve the performance of your applications by stringing data types and implementing hash structures in algorithm design. Finally, you'll be able to apply traditional data structures to solve real-world problems. By the end of the book, you'll have become adept at implementing classic data structures and algorithms in Go, propelling you to become a confident Go programmer.
Table of Contents (16 chapters)
Free Chapter
1
Section 1: Introduction to Data Structures and Algorithms and the Go Language
4
Section 2: Basic Data Structures and Algorithms using Go
11
Section 3: Advanced Data Structures and Algorithms using Go

What this book covers

Chapter 1, Data Structures and Algorithms, focuses on the definition of abstract data types, classifying data structures into linear, non-linear, homogeneous, heterogeneous, and dynamic types. Abstract data types, such as container, list, set, map, graph, stack, and queue, are presented in this chapter. This chapter also covers the performance analysis of data structures, as well as the correct choice of data structures and structural design patterns.

Chapter 2, Getting Started with Go for Data Structures and Algorithms, covers Go-specific data structures, such as arrays, slices, two-dimensional slices, maps, structs, and channels. Variadic functions, deferred function calls, and panic and recover operations are introduced. Slicing operations, such as enlarging using append and copy, assigning parts, appending a slice, and appending part of a slice, are also presented in this chapter.

Chapter 3, Linear Data Structures, covers linear data structures such as lists, sets, tuples, stacks, and heaps. The operations related to these types, including insertion, deletion, updating, reversing, and merging are shown with various code samples. In this chapter, we present the complexity analysis of various data structure operations that display accessing, search, insertion, and deletion times.

Chapter 4, Non-Linear Data Structures, covers non-linear data structures, such as trees, tables, containers, and hash functions. Tree types, including binary tree, binary search tree, T-tree, treap, symbol table, B- tree, and B+ tree, are explained with code examples and complexity analysis. Hash function data structures are presented, along with examples in cryptography for a variety of scenarios, such as open addressing, linear probing, universal hashing, and double hashing.

Chapter 5, Homogeneous Data Structures, covers homogeneous data structures such as two-dimensional and multi-dimensional arrays. Array shapes, types, literals, printing, construction, indexing, modification, transformation, and views are presented together with code examples and performance analysis. Matrix representation, multiplication, addition, subtraction, inversion, and transpose scenarios are shown to demonstrate the usage of multi-dimensional arrays.

Chapter 6, Heterogeneous Data Structures, covers heterogeneous data structures, such as linked lists, ordered, and unordered lists. We present the singly linked list, doubly linked list, and circular linked list, along with code samples and efficiency analysis. Ordered and unordered lists from HTML 3.0 are shown to demonstrate the usage of lists and storage management.

Chapter 7, Dynamic Data Structures, covers dynamic data structures, such as dictionaries, TreeSets, and sequences. Synchronized TreeSets and mutable TreeSets are covered in this chapter along with Go code exhibits. Sequence types including Farey, Fibonacci, look-and-say, and Thue-Morse, are discussed with Go programs. This chapter also explains the usage anti-patterns of dictionaries, TreeSets, and sequences.

Chapter 8, Classic Algorithms, covers pre-order, post-order, in-order, level-order tree traversals and linked list traversals. Sorting algorithms, such as bubble, selection, insertion, shell, merge, and quick are explained with code exhibits. Search algorithms, as well as linear, sequential, binary, and interpolation methods, are also covered in this chapter. Recursion and hashing are shown by means of code samples.

Chapter 9, Network and Sparse Matrix Representation, covers data structures such as graphs and lists of lists. Different use cases from real-life applications, such as social network representation, map layouts, and knowledge catalogs, are shown with code examples and efficiency analysis.

Chapter 10, Memory Management, covers dynamic data structures, such as AVL trees and stack frames. Garbage collection, cache management, and space allocation algorithms are presented with code samples and efficiency analysis. Garbage collection algorithms, such as simple/deferred/one-bit/weighted reference counting, mark and sweep, and generational collection, are explained with an analysis of their advantages and disadvantages.

Appendix, Next Steps, shares the learning outcomes for the reader arising from the book. The code repository links and key takeaways are presented. References are included for the latest data structures and algorithms. Tips and techniques are provided to keep yourself updated with the latest on data structures and algorithms.