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)

Chapter 3. Stacks and Queues

So far, you have learned a lot about arrays and lists. However, these structures are not the only ones available. Among others, there is also a group of more specialized data structures, which are called limited access data structures.

What does this mean? To explain the name, let's return to the topic of arrays for the moment, which belong to the group of random access data structures. The difference between them is only one word, that is, limited or random. As you already know, arrays allow you to store data and get access to various elements using indices. Thus, you can easily get the first, the middle, the nth, or the last element from the array. For this reason, it can be named as the random access data structure.

However, what does limited mean? The answer is very simple—with a limited access data structure, you cannot access every element from the structure. Thus, the way of getting elements is strictly specified. For example, you can get only the first...