O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

C# Data Structures and Algorithms

Book Description

A complete guide on using data structures and algorithms to write sophisticated C# code

About This Book
  • 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 for developers who would like to learn the Data Structures and Algorithms in C#. Basic C# programming knowledge would be an added advantage.

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
In Detail

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.

Style and approach

Readers will be taken through all the indispensable data structures and algorithms so they can begin their coding journey in C#. At each step, the book will show how to implement these via examples while also discussing the attributes of each algorithm so readers are capable to make an informed choice.

Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Title Page
  2. Copyright and Credits
    1. C# Data Structures and Algorithms
  3. Packt Upsell
    1. Why subscribe?
    2. PacktPub.com
  4. Contributors
    1. About the author
    2. About the reviewer
    3. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  6. Getting Started
    1. Programming language
    2. Data types
      1. Value types
        1. Structs
        2. Enumerations
      2. Reference types
        1. Strings
        2. Object
        3. Dynamic
        4. Classes
        5. Interfaces
        6. Delegates
    3. Installation and configuration of the IDE
    4. Creating the project
    5. Input and output
      1. Reading from input
      2. Writing to output
    6. Launching and debugging
    7. Summary
  7. Arrays and Lists
    1. Arrays
      1. Single-dimensional arrays
        1. Example – month names
      2. Multi-dimensional arrays
        1. Example – multiplication table
        2. Example – game map
      3. Jagged arrays
        1. Example – yearly transport plan
    2. Sorting algorithms
      1. Selection sort
      2. Insertion sort
      3. Bubble sort
      4. Quicksort
    3. Simple lists
      1. Array list
      2. Generic list
      3. Example – average value
      4. Example – list of people
    4. Sorted lists
      1. Example – address book
    5. Linked lists
      1. Example – book reader
    6. Circular-linked lists
      1. Implementation
      2. Example – spin the wheel
    7. Summary
  8. Stacks and Queues
    1. Stacks
      1. Example – reversing words
      2. Example – Tower of Hanoi
    2. Queues
      1. Example – call center with a single consultant
      2. Example – call center with many consultants
    3. Priority queues
      1. Example – call center with priority support
    4. Summary
  9. Dictionaries and Sets
    1. Hash tables
      1. Example – phone book
    2. Dictionaries
      1. Example – product location
      2. Example – user details
    3. Sorted dictionaries
      1. Example – definitions
    4. Hash sets
      1. Example – coupons
      2. Example – swimming pools
    5. "Sorted" sets
      1. Example – removing duplicates
    6. Summary
  10. Variants of Trees
    1. Basic trees
      1. Implementation
        1. Node
        2. Tree
      2. Example – hierarchy of identifiers
      3. Example – company structure
    2. Binary trees
      1. Implementation
        1. Node
        2. Tree
      2. Example – simple quiz
    3. Binary search trees
      1. Implementation
        1. Node
        2. Tree
        3. Lookup
        4. Insertion
        5. Removal
      2. Example – BST visualization
    4. AVL trees
      1. Implementation
      2. Example – keep the tree balanced
    5. Red-black trees
      1. Implementation
      2. Example – RBT-related features
    6. Binary heaps
      1. Implementation
      2. Example – heap sort
    7. Binomial heaps
    8. Fibonacci heaps
    9. Summary
  11. Exploring Graphs
    1. Concept of graphs
    2. Applications
    3. Representation
      1. Adjacency list
      2. Adjacency matrix
    4. Implementation
      1. Node
      2. Edge
      3. Graph
      4. Example – undirected and unweighted edges
      5. Example – directed and weighted edges
    5. Traversal
      1. Depth-first search
      2. Breadth-first search
    6. Minimum spanning tree
      1. Kruskal's algorithm
      2. Prim's algorithm
      3. Example – telecommunication cable
    7. Coloring
      1. Example – voivodeship map
    8. Shortest path
      1. Example – game map
    9. Summary
  12. Summary
    1. Classification of data structures
    2. Diversity of applications
      1. Arrays
      2. Lists
      3. Stacks
      4. Queues
      5. Dictionaries
      6. Sets
      7. Trees
      8. Heaps
      9. Graphs
    3. The last word
  13. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think