▶Book Description
Data structures allow organizing data efficiently. They are critical to various problems and their suitable implementation can provide a complete solution that acts like reusable code. In this book, you will learn how to use various data structures while developing in the C# language as well as how to implement some of the most common algorithms used with such data structures.
At the beginning, you will get to know arrays, lists, dictionaries, and sets together with real-world examples of your application. Then, you will learn how to create and use stacks and queues. In the following part of the book, the more complex data structures will be introduced, namely trees and graphs, together with some algorithms for searching the shortest path in a graph. We will also discuss how to organize the code in a manageable, consistent, and extendable way. By the end of the book,you will learn how to build components that are easy to understand, debug, and use in different applications.
▶What You Will Learn
- How to use arrays and lists to get better results in complex scenarios
- Implement algorithms like the Tower of Hanoi on stacks of C# objects
- Build enhanced applications by using hashtables, dictionaries and sets
- Make a positive impact on efficiency of applications with tree traversal
- Effectively find the shortest path in the graph
▶Key Features
- Master array, set and map with trees and graphs, among other fundamental data structures
- Delve into effective design and implementation techniques to meet your software requirements
- Explore illustrations to present data structures and algorithms, as well as their analysis in a clear, visual manner.
▶Who This Book Is For
This book is aimed at developers who would like to learn about the data structures and algorithms that can be used in C# in various kinds of applications, including web and mobile solutions. The topics presented here are suitable for programmers with various levels of experience, and even beginners will find interesting content. However, having at least a basic knowledge of the C# programming language, such as about object-oriented programming, will be an added advantage.
To easily understand the content, the book is equipped with many illustrations and examples. What's more, the source code for the accompanying projects is attached to the chapters. Thus, you can easily run example applications and debug them without writing the code on your own.
It is worth mentioning that the code can be simplified, and it can differ from the best practices. What's more, the examples can have significantly limited, or even no, security checks and functionalities. Before publishing your application using the content presented in the book, the application should be thoroughly tested to ensure that it works correctly in various circumstances, such as in the scenario of passing incorrect data.
▶What this book covers
- Chapter 1, Getting Started, explains the very important role of using the right data structures and algorithms, as well as the impact it has on the performance of the developed solution. The chapter briefly introduces you to the topic of the C# programming language and various data types—.both value and reference. Then, it presents the process of the installation and configuration of the IDE, as well as the creation of a new project, developing the example application, and debugging using breakpoints and the step-by-step technique.
- Chapter 2, Arrays and Lists, covers scenarios of storing data using two kinds of random access data structures, namely arrays and lists. First, three variants of arrays are explained, that is, single-dimensional, multi-dimensional, and jagged. You will also get to know four sorting algorithms, namely selection, insertion, bubble sort, and quicksort. The chapter also deals with a few variants of lists, such as simple, sorted, double-linked, and circular-linked.
- Chapter 3, Stacks and Queues, explains how to use two variants of limited access data structures, namely stacks and queues, including priority queues. The chapter shows how to perform push and pop operations on a stack, and also describes the enqueue and dequeue operations in the case of a queue. To aid your understanding of these topics, a few examples are presented, including the Tower of Hanoi game and an application that simulates a call center with multiple consultants and callers.
- Chapter 4, Dictionaries and Sets, focuses on data structures related to dictionaries and sets, which make it possible to map keys to values, perform fast lookup, and carry out various operations on sets. The chapter introduces you to both nongeneric and generic variants of a hash table, the sorted dictionary, and the high-performance solution to set operations, together with the concept of the "sorted" set.
- Chapter 5, Variants of Trees, describes a few tree-related topics. It presents the basic tree together with its implementation in C#, and examples showing this in action. The chapter also introduces you to binary trees, binary search trees, and self-balancing trees, namely AVL and red-black trees. The remainder of the chapter is dedicated to heaps as tree-based structures, that is, the binary, binomial, and Fibonacci heaps.
- Chapter 6, Exploring Graphs, contains a lot of information about graphs, starting with an explanation of their basic concepts, including nodes and a few variants of edges. The implementation of a graph in C# is also covered. The chapter introduces you to two modes of graph traversal, namely depth-first and breadth-first search. Then, it presents the subject of minimum spanning trees using Kruskal's and Prim's algorithms, the node coloring problem, and the solution to finding the shortest path in a graph using Dijkstra's algorithm.
Chapter 7, Summary, is the conclusion to all the knowledge acquired from the previous chapters. It shows a brief classification of data structures, dividing them into two groups, namely linear and nonlinear. Finally, the chapter talks about the diversity of the applications of various data structures.