Book Image

C# Data Structures and Algorithms

By : Marcin Jamro
Book Image

C# Data Structures and Algorithms

By: Marcin Jamro

Overview of this book

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.
Table of Contents (14 chapters)

Summary


This fourth chapter of the book focused on hash tables, dictionaries, and sets. All of these collections are interesting data structures that can be used in various scenarios. By presenting such collections with detailed descriptions and examples, you have seen that choosing a proper data structure is not a trivial task and requires analysis of performance-related topics, because some of them operate better in retrieving values and some promote the addition and removal of data.

At the beginning, you have learned how to use two variants of a hash table, namely non-generic (the Hashtable class) and generic (Dictionary). The huge advantage of these is the very fast lookup for a value based on the key, which is the close O(1) operation. To achieve this goal, the hash function is used. Moreover, the sorted dictionary has been introduced as an interesting solution to solve the problem of unsorted items in the collection and to keep keys sorted all the time.

Afterwards, the high-performance...